help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: programming help


From: insipido
Subject: Re: programming help
Date: Wed, 17 Nov 2010 15:53:47 -0200

Oisin...

the eval() option seems to work perfectly for me.

thank you very much that is why I love GNU community.


On 17/11/2010, at 02:57 p.m., OCuanachain, Oisin (Oisin) wrote:

You could use an array:

for i = 1:a
   c(i) = b+i;
endfor

Then you would have
c(1) = 11
c(2) = 12
etc.

OR you could use eval()

for i = 1:a
   eval(['c' num2str(i) ' = b+i']);
endfor

This would give you exactly what you requested:
c1 = 11
c2 = 12
etc

-----Original Message-----
From: insipido [mailto:address@hidden
Sent: 17 November 2010 16:53
To: address@hidden
Subject: programming help

Hi
I am not so good for programing, but I do my best.
I wanted do know if it is possible to obtain in return a numbered
variable.
I would like to save in different variables the result of a for cycle.

for example:

a = 5;
b = 2*a;
for i = 1:a
   c = b+i
endfor

the result is:

c=11
c=12
c=13
c=14
c=15

but then, 'c' ends with value =15, but what about I want to save in
different variables other results, like:

c1=11
c2=12
c3=13
c4=14
c5=15

and in that way I could easily call them independently.

any idea, please help me.

thanks

victor./

_______________________________________________
Help-octave mailing list
address@hidden
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave



reply via email to

[Prev in Thread] Current Thread [Next in Thread]