matlab - ArrayFun with multiple input -


i have problem while using arrayfun in matlab. have vector of angles , want avoid for loop , apply:

rmatrix1 = arrayfun(...     @(x) anglesloop(iblade, iradius, jradius, ifrequency, x, rot), ...     angles, 'uniformoutput', false); 

where iblade = 1, iradius = 1, jradius = 1, ifrequency = 1 , rot = 0.5.

the function looks like:

%% angles loop function rmatrix = anglesloop(iblade, iradius, jradius, ifrequency, angles, rot) global frequency blade fshifted =(frequency(ifrequency)-angles*rot); s11 = kaimal(fshifted); s22 = s11;                  r = distance(iradius,jradius,angles); aux = (3/(2*pi)).*coherence(r).*exp(-1i*angles*ifrequency*blade(iblade)/3);                 rmatrix = (sqrt(s11).*sqrt(s22).*aux.*exp(1i*2*pi.*angles.*1/3)); end 

with subfunctions

%% distance coherence function function r=distance(x1,x2,theta)  r = sqrt(x1^2+x2^2- 2*x1*x2*cos(theta)); end 

and

%% coherence function gamma=coherence(r) global frequency v10 l1 if r==0    gamma=1; else    gamma=exp(-12.*sqrt((frequency.*r./v10).^2+(0.12.*r./l1).^2)); end 

the problem when apply anglesloop function in arrayfun obtain cell of 64 different arrays whereas should obtain vector of 64 angles length. rmatrix1 should vector of 64 elements. can give me recommendation?

i think problem you're asking 'uniformoutput', false causes return cell array. need concatenate contents of cell array, can cell2mat. here's simpler example. i've got row vector, , i'm applying function turns each element 2x2 matrix. want end of these small matrices concatenated together.

rowvector = 1:5; myfcn = @(x) [x, -x; -x, x]; separatematricescell = arrayfun(myfcn, rowvector, 'uniformoutput', false); concatenatedmatrices = cell2mat(separatematricescell) 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -