From: us on
"SteveR R" <whatever(a)whatever.com> wrote in message <hsn3bp$b2p$1(a)fred.mathworks.com>...
> Thanks for your replies. I eventually need to start creating matrices based on a user inputted number, is there nothing I can do in Matlab which would resembe the C++ code:
> int main()
> {
> for (int i=0;i<10;i++)
> {
> int Si=i;
> cout << Si << endl;
> }
>
> return 0;
>
> }
> This is what I was trying to show with my first example.
>
> Cheers
> Stevie

first, top post(!)...
then,
- now you're changing the story...
in general, this is not well received in this NG because CSSMers quickly feel
that they've wasted their time...
- please, provide ML equivalent code...
note: i'm VERY fluent in C and siblings, but this NG is dedicated to ML...

us
From: John O'Flaherty on
On Sat, 15 May 2010 21:23:05 +0000 (UTC), "SteveR R"
<whatever(a)whatever.com> wrote:

>Thanks for your replies. I eventually need to start creating matrices based on a user inputted number, is there nothing I can do in Matlab which would resembe the C++ code:
>int main()
>{
>for (int i=0;i<10;i++)
>{
> int Si=i;
> cout << Si << endl;
>}
>
>return 0;
>
>}
>This is what I was trying to show with my first example.

Stevie, do you mean Si to be an array, rather than a single variable
that gets a new value with each loop iteration? If so, you'd have to
use S[i].
--
John
From: SteveR R on
In this example I do not mean Si to be an array, I am creating integer variables over the loop, so the first variable I create is an integer called S0 and give it the value 0, then I create an integer called S1 and give it the value 1, etc... This allows me to create a number of differnet variables based on how big the loop is.

My guess at what the equivalent ML code would be:

for i=0:9
Si=i;
end

But this doesn't created S0, S1, S2 etc.



John O'Flaherty <quiasmox(a)yeeha.com> wrote in message <ke5uu597lrq159odkpko0ju4j4fef6850a(a)4ax.com>...
> On Sat, 15 May 2010 21:23:05 +0000 (UTC), "SteveR R"
> <whatever(a)whatever.com> wrote:
>
> >Thanks for your replies. I eventually need to start creating matrices based on a user inputted number, is there nothing I can do in Matlab which would resembe the C++ code:
> >int main()
> >{
> >for (int i=0;i<10;i++)
> >{
> > int Si=i;
> > cout << Si << endl;
> >}
> >
> >return 0;
> >
> >}
> >This is what I was trying to show with my first example.
>
> Stevie, do you mean Si to be an array, rather than a single variable
> that gets a new value with each loop iteration? If so, you'd have to
> use S[i].
> --
> John
From: us on
"SteveR R" <whatever(a)whatever.com> wrote in message <hsn6mq$or5$1(a)fred.mathworks.com>...
> In this example I do not mean Si to be an array, I am creating integer variables over the loop, so the first variable I create is an integer called S0 and give it the value 0, then I create an integer called S1 and give it the value 1, etc... This allows me to create a number of differnet variables based on how big the loop is.
>
> My guess at what the equivalent ML code would be:
>
> for i=0:9
> Si=i;
> end
>
> But this doesn't created S0, S1, S2 etc.
>
>
>
> John O'Flaherty <quiasmox(a)yeeha.com> wrote in message <ke5uu597lrq159odkpko0ju4j4fef6850a(a)4ax.com>...
> > On Sat, 15 May 2010 21:23:05 +0000 (UTC), "SteveR R"
> > <whatever(a)whatever.com> wrote:
> >
> > >Thanks for your replies. I eventually need to start creating matrices based on a user inputted number, is there nothing I can do in Matlab which would resembe the C++ code:
> > >int main()
> > >{
> > >for (int i=0;i<10;i++)
> > >{
> > > int Si=i;
> > > cout << Si << endl;
> > >}
> > >
> > >return 0;
> > >
> > >}
> > >This is what I was trying to show with my first example.
> >
> > Stevie, do you mean Si to be an array, rather than a single variable
> > that gets a new value with each loop iteration? If so, you'd have to
> > use S[i].
> > --
> > John

DO NOT TOP POST!!!!!
then, carefully read this...

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

in particular, the very first sentence...

us
From: SteveR R on
ANyway thanks for your replies Ill figure something else out and thanks for the reference.