AndrewC
unread,Apr 5, 2012, 6:35:02 PM4/5/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to freemat
Not sure if this is a known issue, but FreeMat 4.1 seems unable to
properly return assign and multi-dimensional arrays from a function
UNLESS you pre-create the array with, say, a zeros function before
assigning elements.
For example, in the function below, if I comment out the
G1_f=zeros(...) line, the array G1_f returned from the function is
'jumbled'.
That is if I , say , assigned an entry of the matrix
G1_f(1,2,4,1,5,3) = 10.0 inside this function, when I examine
G1_f(1,2,4,1,5,3) back in the calling function or workspace the entry
will NOT be 10.0.
function [G1_f] = test (S_Afxy)
[nof_ave,nof_f,nof_x,nof_y] = size(S_Afxy)
%G1_f=zeros(nof_x,nof_y,nof_x,nof_y,nof_ave,nof_f); <- this line
must active to avoid issue.
for (b = 0:1:nof_y-1)
for (a = 0:1:nof_x-1)
for (j = 1:1:nof_y-b)
for (i = 1:1:nof_x-a)
for (c = 1:1:nof_ave)
Cross = conj(S_Afxy(c,:,i,j)).*S_Afxy(c,:,i+a,j
+b);
G1_f(a+1,b+1,i,j,c,:) = Cross ;
end
end
end
end
end
end