From: Brendan on
"Brendan " <btracey(a)stanford.edu> wrote in message <hm21k6$8s8$1(a)fred.mathworks.com>...
> Nathan <ngreco32(a)gmail.com> wrote in message <70c137ea-91ee-4cf6-aa1e-c52bf6f32ed2(a)b36g2000pri.googlegroups.com>...
> > Ah... I guess test data wasn't too tough to come up with. Here it is,
> > and I hope this is what you're looking for:
> > EofGgivenXjU{1}=[0,0,0,0];
> > EofGgivenXjU{2}=[1,1,1,1];
> > EofGgivenXjU{3}=[1:4];
> > numIter = length(EofGgivenXjU{1});
> > numVars = length(EofGgivenXjU);
> > for ii=1:numIter
> > newTermU=3*ii;
> > jj=1:numVars;
> > tmp{ii} = cellfun(@(x)x(ii) + newTermU,EofGgivenXjU)
> > end
> >
> > Note that the tmp variable contains the new cell arrays. Disperse them
> > as you like.
> >
> > -Nathan
>
> Hey, sorry, I posted my thing before I saw this reply.
> Two points
> 1) In that code you have there it doesn't seem like you actually use jj anywhere
> 2) I was wondering if you could either explain or direct me to an explaination of the @(x)x(ii) part. I'm having trouble parsing what that means.
>
> Thanks again.

Nevermind on question 2, I understand it I think.
From: Nathan on
On Feb 23, 6:07 pm, "Brendan " <btra...(a)stanford.edu> wrote:
> Nathan <ngrec...(a)gmail.com> wrote in message <70c137ea-91ee-4cf6-aa1e-c52bf6f32...(a)b36g2000pri.googlegroups.com>...
> > Ah... I guess test data wasn't too tough to come up with. Here it is,
> > and I hope this is what you're looking for:
> > EofGgivenXjU{1}=[0,0,0,0];
> > EofGgivenXjU{2}=[1,1,1,1];
> > EofGgivenXjU{3}=[1:4];
> > numIter = length(EofGgivenXjU{1});
> > numVars = length(EofGgivenXjU);
> > for ii=1:numIter
> >     newTermU=3*ii;
> >     jj=1:numVars;
> >     tmp{ii} = cellfun(@(x)x(ii) + newTermU,EofGgivenXjU)
> > end
>
> > Note that the tmp variable contains the new cell arrays. Disperse them
> > as you like.
>
> > -Nathan
>
> Hey, sorry, I posted my thing before I saw this reply.
> Two points
> 1) In that code you have there it doesn't seem like you actually use jj anywhere
> 2) I was wondering if you could either explain or direct me to an explaination of the @(x)x(ii) part. I'm having trouble parsing what that means.
>
> Thanks again.

Ah, I accidentally left the jj part in there. Instead of looping
through cells, the cellfun takes care of each cell individually.

Was that code sufficient for you?

And for the second question, whether you understand it or not:
for ii=1:numIter
newTermU=3*ii;
tmp{ii} = cellfun(@(x)x(ii) + newTermU,EofGgivenXjU)
end
x is the parameter to the anonymous function that does x(ii) +
newTermU.
EofGgivenXjU is passed in as x, therefore for each cell in
EofGgivenXju, it will look for the ii'th item and add newTermU to it.

I didn't, at the time, have your D variable, so I used ii as a
temporary value for an example.

I hope that helps clear things up.

-Nathan
From: Brendan on
Nathan <ngreco32(a)gmail.com> wrote in message <7e92466f-add5-4d0f-abc1-40693e49ddbe(a)u19g2000prh.googlegroups.com>...
> On Feb 23, 6:07 pm, "Brendan " <btra...(a)stanford.edu> wrote:
> > Nathan <ngrec...(a)gmail.com> wrote in message <70c137ea-91ee-4cf6-aa1e-c52bf6f32...(a)b36g2000pri.googlegroups.com>...
> > > Ah... I guess test data wasn't too tough to come up with. Here it is,
> > > and I hope this is what you're looking for:
> > > EofGgivenXjU{1}=[0,0,0,0];
> > > EofGgivenXjU{2}=[1,1,1,1];
> > > EofGgivenXjU{3}=[1:4];
> > > numIter = length(EofGgivenXjU{1});
> > > numVars = length(EofGgivenXjU);
> > > for ii=1:numIter
> > >     newTermU=3*ii;
> > >     jj=1:numVars;
> > >     tmp{ii} = cellfun(@(x)x(ii) + newTermU,EofGgivenXjU)
> > > end
> >
> > > Note that the tmp variable contains the new cell arrays. Disperse them
> > > as you like.
> >
> > > -Nathan
> >
> > Hey, sorry, I posted my thing before I saw this reply.
> > Two points
> > 1) In that code you have there it doesn't seem like you actually use jj anywhere
> > 2) I was wondering if you could either explain or direct me to an explaination of the @(x)x(ii) part. I'm having trouble parsing what that means.
> >
> > Thanks again.
>
> Ah, I accidentally left the jj part in there. Instead of looping
> through cells, the cellfun takes care of each cell individually.
>
> Was that code sufficient for you?
>
> And for the second question, whether you understand it or not:
> for ii=1:numIter
> newTermU=3*ii;
> tmp{ii} = cellfun(@(x)x(ii) + newTermU,EofGgivenXjU)
> end
> x is the parameter to the anonymous function that does x(ii) +
> newTermU.
> EofGgivenXjU is passed in as x, therefore for each cell in
> EofGgivenXju, it will look for the ii'th item and add newTermU to it.
>
> I didn't, at the time, have your D variable, so I used ii as a
> temporary value for an example.
>
> I hope that helps clear things up.
>
> -Nathan

Thank you for your help. I'm still working things out, but at the very least my original question has been answered, and you have pointed me in the right path on step two :)