From: Eli Melaas on
I would like to change the name of pre-existing variables in a for loop such as the following:

for i =2:6
UM.ET.hh0i = UM.UM0i.L4(:,17);
UM.H.hh0i = UM.UM0i.L4(:,15);
UM.Rn.hh0i = UM.UM0i.L4(:,5);
UM.VPD.hh0i = UM.UM0i.L4(:,9);
UM.Temp.hh0i = UM.UM0i.L4(:,11);
UM.friction.hh02 = UM.UM0i.L2(:,6);
UM.wind.hh02 = UM.UM0i.L2(:,9);
end

where I have already created UM.ET.hh02, UM.Rn.hh02, etc.

Thanks!
From: Rob Campbell on
I do not understand the question. However, is it possible that this helps you:
>> tmp='BLOB';
>> T.(tmp)='hello';
>> T.BLOB

ans =

hello
From: Rob Campbell on
Please don't post the same question 3 times.
Take time to explain exactly what you want, if you desire a useful answer.
From: Eli Melaas on
"Rob Campbell" <matlab(a)robertREMOVEcampbell.removethis.co.uk> wrote in message <hodvh1$4h4$1(a)fred.mathworks.com>...
> Please don't post the same question 3 times.
> Take time to explain exactly what you want, if you desire a useful answer.

Hi Rob,

I apologize for the multiple posts and poor explanation. Perhaps this is more helpful:

I have half-hourly time series for multiple variables (ET, H, Rn, wind, friction, etc.) and multiple years (2002, 2003, 2004, 2005, 2006). These time series are at this point columns in a matrix ("L4") within a structure ("UM.UM02"). I would like to construct a for loop such that, rather than doing the following repetitive process.....

UM.ET.hh02 = UM.UM02.L4(:,17);
UM.ET.hh03 = UM.UM03.L4(:,17);
UM.ET.hh04 = UM.UM04.L4(:,17);
UM.ET.hh05 = UM.UM05.L4(:,17);
UM.ET.hh06 = UM.UM06.L4(:,17);

......I can simply have the for loop call the last number of the year (2, 3, 4, 5, etc. )
where the "i" is called as so:

for i = 2:6
UM.ET.hh0i = UM.UM0i.L4(:,17);
end

I assume there must be some sort of number to string converter that can achieve this?

Thanks,
Eli
From: Walter Roberson on
Eli Melaas wrote:

> I apologize for the multiple posts and poor explanation. Perhaps this is
> more helpful:

I understood the first time, but I figured someone else would pop up with the
answer first. And Rob's first response was how you *should* handle things.

You have a particular approach in mind, but it is our duty to try to convince
you to change your mind. Please read the Matlab FAQ on exactly this issue:

http://matlabwiki.mathworks.com/MATLAB_FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F