Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
numbering of output variables of a loop (simple)

Subject: numbering of output variables of a loop (simple)

From: John Dim

Date: 3 May, 2010 10:47:08

Message: 1 of 4

Hello,

lets say that I have the very simple loop

for i = 1:10

s(i) = i+1

end

why do I get an error?
All I want is to get: s1=2, s2=3 ..etc.
Is there any other way that I can put numbering on s values?

Subject: numbering of output variables of a loop (simple)

From: Sean

Date: 3 May, 2010 11:38:06

Message: 2 of 4

"John Dim" <mitsoujohn@yahoo.com> wrote in message <hrm9jc$ecj$1@fred.mathworks.com>...
> Hello,
>
> lets say that I have the very simple loop
>
> for i = 1:10
>
> s(i) = i+1
>
> end
>
> why do I get an error?
> All I want is to get: s1=2, s2=3 ..etc.
> Is there any other way that I can put numbering on s values?


>>s = 2:11;

Subject: numbering of output variables of a loop (simple)

From: Steven Lord

Date: 3 May, 2010 13:24:33

Message: 3 of 4


"John Dim" <mitsoujohn@yahoo.com> wrote in message
news:hrm9jc$ecj$1@fred.mathworks.com...
> Hello,
>
> lets say that I have the very simple loop
>
> for i = 1:10
>
> s(i) = i+1
>
> end
>
> why do I get an error?
> All I want is to get: s1=2, s2=3 ..etc.
> Is there any other way that I can put numbering on s values?

Yes, but you should not do this. See Q4.6 in the newsgroup FAQ for a
discussion of this issue.

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

Subject: numbering of output variables of a loop (simple)

From: John Dim

Date: 4 May, 2010 10:53:03

Message: 4 of 4

"Steven Lord" <slord@mathworks.com> wrote in message <hrmiqg$bne$1@fred.mathworks.com>...
>
> "John Dim" <mitsoujohn@yahoo.com> wrote in message
> news:hrm9jc$ecj$1@fred.mathworks.com...
> > Hello,
> >
> > lets say that I have the very simple loop
> >
> > for i = 1:10
> >
> > s(i) = i+1
> >
> > end
> >
> > why do I get an error?
> > All I want is to get: s1=2, s2=3 ..etc.
> > Is there any other way that I can put numbering on s values?
>
> Yes, but you should not do this. See Q4.6 in the newsgroup FAQ for a
> discussion of this issue.
>
> --
> Steve Lord
> slord@mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
>
Thanks Steve, very useful I'll use structures.
cheers I appreciate your help.
John D.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us