From: Alessandro on
Hi guys,

I'd like to connect a parameter name to a moving number, performing for example the following loop:

for i=1:10
parameter "i"
end

I want the following output :

parameter 1
parameter 2
..........
parameter 10

How I can write this in Matlab?

Thks for help!
Ciao ciao!
From: Steven Lord on

"Alessandro " <alessandro.ambrosone(a)libero.it> wrote in message
news:hqs9m0$mi4$1(a)fred.mathworks.com...
> Hi guys,
>
> I'd like to connect a parameter name to a moving number, performing for
> example the following loop:
>
> for i=1:10
> parameter "i"
> end
>
> I want the following output :
>
> parameter 1
> parameter 2
> .........
> parameter 10
>
> How I can write this in Matlab?

That depends ... what are you trying to do with this connected parameter
name and number? If you're trying to create variables named parameter1,
parameter2, parameter3, etc. then you should not do this for reasons
described in question 4.6 in the newsgroup FAQ. If you're just looking to
display those strings, use FPRINTF or SPRINTF.

for k = 1:10
fprintf('parameter %d\n', k);
end

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


From: Alessandro on
> That depends ... what are you trying to do with this connected parameter
> name and number? If you're trying to create variables named parameter1,
> parameter2, parameter3, etc. then you should not do this for reasons
> described in question 4.6 in the newsgroup FAQ. If you're just looking to
> display those strings, use FPRINTF or SPRINTF.
>
> for k = 1:10
> fprintf('parameter %d\n', k);
> end
>
> --
> Steve Lord
> slord(a)mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
>
Hi Steve,

thks for your reply!
I try to explain what really I'd like to do.
I have a big vector "A" of 1000 elements (but the dimension could be variable).
I want to create 10 new vectors of 100 elements each.
These new vectors shall have the following names:

A1 = first 100 elements of "A"
A2 = second 100 elements of "A"
and so on....

So I need an incremental number to link to the fixed part "A".

Regards
Ale
From: Steven Lord on

"Alessandro " <alessandro.ambrosone(a)libero.it> wrote in message
news:hr3b5j$ei7$1(a)fred.mathworks.com...

*snip*

> Hi Steve,
>
> thks for your reply!
> I try to explain what really I'd like to do.
> I have a big vector "A" of 1000 elements (but the dimension could be
> variable).
> I want to create 10 new vectors of 100 elements each.
> These new vectors shall have the following names:
>
> A1 = first 100 elements of "A"
> A2 = second 100 elements of "A"
> and so on....
>
> So I need an incremental number to link to the fixed part "A".

Don't do this. See Q4.6 in the newsgroup FAQ for alternatives.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


From: Alessandro on

> Don't do this. See Q4.6 in the newsgroup FAQ for alternatives.
>
> --
> Steve Lord
> slord(a)mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
>


Hi Steve,

in 4.6 of Matlab_FAQ I found that code:

for i=1:10
eval(sprintf('A%d = [1:i]', i));
end

and it looks interesting...thanks for the suggestion!!

Bye bye!