From: Markthomas on 24 Apr 2010 22:10 I have imported data that has the following information: Q.PR_1 Q.PR_2 Q.PR_3 each of the PR_# have a n x m matrix. I need to loop through all these data points how can I setup a loop like: for i = 1:3 sol(i) = Q.PR_i(1,1) ????? end thanks MT
From: ImageAnalyst on 24 Apr 2010 23:18 Well heck, if there are only three of them, simply use three for loops, each with one of the names. No need to make it trickier. I'm not really sure what you're after with that assignment to sol though....
From: us on 25 Apr 2010 00:01 "Markthomas " <cutonem(a)clarkson.edu> wrote in message <hr08ad$rqd$1(a)fred.mathworks.com>... > I have imported data that has the following information: > > Q.PR_1 > Q.PR_2 > Q.PR_3 > > each of the PR_# have a n x m matrix. I need to loop through all these data points how can I setup a loop like: > > for i = 1:3 > sol(i) = Q.PR_i(1,1) ????? > end > > thanks > > MT one of the solutions q.pr_1=1; q.pr_2=1:2; q.pr_3=1:3; fn=fieldnames(q); for i=1:numel(fn) cf=fn{i}; r=mean(q.(cf)); disp(sprintf('working on data set %s: mean = %7.3f',cf,r)); end %{ working on data set pr_1: mean = 1.000 working on data set pr_2: mean = 1.500 working on data set pr_3: mean = 2.000 %} us
From: TideMan on 25 Apr 2010 00:27 On Apr 25, 2:10 pm, "Markthomas " <cuto...(a)clarkson.edu> wrote: > I have imported data that has the following information: > > Q.PR_1 > Q.PR_2 > Q.PR_3 > > each of the PR_# have a n x m matrix. I need to loop through all these data points how can I setup a loop like: > > for i = 1:3 > sol(i) = Q.PR_i(1,1) ????? > end > > thanks > > MT This is the folly of using such nomenclature. If you'd used a structure array instead like this: Q(1).PR, Q(2).PR, Q(3).PR a loop would have been straightforward.
From: Thomas Britton on 25 Apr 2010 06:23
How does the memory cope with such structure arrays? I'm having trouble with a 4d array approx (230,120,30,100) elements and keep on running into memory errors. I've coarsely split the array down a bit (into 3 smaller ones, dividing the 3rd dimension up) but I've got to then manually work out which bit to index and correct appropriately (which works to an extent but is very ugly). I've maxed out the memory settings (on a 4gb 32bit win xp set up). I've got access to an 8gb/32gb ram computer but would rather work on this data on my local computer. Ben TideMan <mulgor(a)gmail.com> wrote in message <6e01d742-059c-4578-a3b6-b9f3406418fb(a)n20g2000prh.googlegroups.com>... > On Apr 25, 2:10 pm, "Markthomas " <cuto...(a)clarkson.edu> wrote: > > I have imported data that has the following information: > > > > Q.PR_1 > > Q.PR_2 > > Q.PR_3 > > > > each of the PR_# have a n x m matrix. I need to loop through all these data points how can I setup a loop like: > > > > for i = 1:3 > > sol(i) = Q.PR_i(1,1) ????? > > end > > > > thanks > > > > MT > > This is the folly of using such nomenclature. > If you'd used a structure array instead like this: > Q(1).PR, Q(2).PR, Q(3).PR > a loop would have been straightforward. |