Prev: symbolic math toolbox 5.4 (matlab 2010a) is too slow compared to math toolbox 3.1
Next: hamming and RS code
From: Shafi on 15 May 2010 12:58 I am a new matlab user and facing a problem while using a for loop. I'll appreciate if anybody help me in this regard. My loop if like below: for i=1:100 [P]=getdata(i); end [P] is i depended and 'getdata' will produce a 40x 40 matrix for each value of i. I want catch all 100, 40x 40 matrix and want to use them in later calculation. Is there anyone who can hep me in this case. Regards Shafi
From: Walter Roberson on 15 May 2010 13:43 Shafi wrote: > I am a new matlab user and facing a problem while using a for loop. I'll > appreciate if anybody help me in this regard. > > My loop if like below: > > for i=1:100 > [P]=getdata(i); > > end > [P] is i depended and 'getdata' will produce a 40x 40 matrix for each > value of i. > I want catch all 100, 40x 40 matrix and want to use them in later > calculation. > > Is there anyone who can hep me in this case. P = cell(100,1); for i = 1:100 P{i} = getdata(i); end Alternately, P = zeros(40,40,100); for i = 1:100 P(:,:,i) = getdata(i); end The second form can be used only for numeric arrays that are all the same size, but is faster. The first form can be used even if getdata() returns different sizes and types of values for the different i.
From: Shafi on 18 May 2010 19:24
Thanks a lot. Your solution was helpful. Regards Shafi "Shafi " <aitmsi(a)yahoo.com> wrote in message <hsmjqu$md5$1(a)fred.mathworks.com>... > I am a new matlab user and facing a problem while using a for loop. I'll appreciate if anybody help me in this regard. > > My loop if like below: > > for i=1:100 > [P]=getdata(i); > > end > [P] is i depended and 'getdata' will produce a 40x 40 matrix for each value of i. > > I want catch all 100, 40x 40 matrix and want to use them in later calculation. > > Is there anyone who can hep me in this case. > Regards > Shafi |