Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Storing of values in an array
Replies: 7   Last Post: Jan 30, 2014 8:44 AM

 Messages: [ Previous | Next ]
 Narayanan Posts: 14 Registered: 6/10/13
Re: Storing of values in an array
Posted: Jan 26, 2014 10:21 AM

Ove R Take <noone@the.moment> wrote in message <lc0asu\$l2r\$1@news.abc.se>...
> Narayanan skrev 2014-01-25 07:37:
> >
> > But that is displaying the final value of SF1 and SF2. This is the code
> > for SF1 where rad2 is a matrix and rows3 is the number of rows of matrix
> > for c=1:(rows3-1)
> > for d=2:rows3
> > alpha=(R*cos(angle*pi/180))/(Vc*Vd);
> > beta=(R*sin(angle*pi/180))/(Vc*Vd);
> > % VS3=
> > else
> > end
> > end
> > This is the code for SF2 where rad3 is a matrix and rows4 is the number
> > of rows of matrix rad3.
> > for c=1:(rows4-1)
> > for d=2:rows4
> > alpha=(R*cos(angle*pi/180))/(Vc*Vd);
> > beta=(R*sin(angle*pi/180))/(Vc*Vd);
> > % VS4=
> > else
> > end
> > end
> > end
> >
> > Now I need to store all the values of SF1 and SF2 (i.e values generated
> > in each iteration) in another array/matrix OV. Now can you help me?
> > enddpb <none@non.net> wrote in message
> > <lbttuv\$ikt\$1@speranza.aioe.org>...

> >> On 1/24/2014 8:25 AM, dpb wrote:
> >> ...
> >>

> >> > But, to answer the question
> >> >
> >> > OV=[SF1 SF2]; % SFx are row vectors
> >> >
> >> > or
> >> >
> >> > OV[SF1;SF2]; % they're column-oriented

> >>
> >> ERRATUM:
> >>
> >> Missing '=' sign, of course...
> >>
> >> OV=[SF1;SF2]; % they're column-oriented
> >>
> >>
> >> --

>
> At the end of your loops you save only the result of the latest loop in
> SF1 and SF2. You overwrite the result of the previous loop. Perhaps this
> is what you want:
>
> ...
> ...
> ...
>
> This way you get two matrices SF1 and SF2 that may be appended:
>
> OV = [SF1;SF2]
>
> You may also have to "preallocate" SF*, using something like
>
> SF1=[];
>
> or better - if you know their sizes - using something like
>
> SF1 = zeros(M,2);

Now as per the suggested idea I tried it but still the same problem persists. Where should I place this SF1 = [ SF1; rad2(c,1) SFrad2 ]? After the first or the second or outside of all the loops? The values are not getting appended but only the last value is getting stored.

Kindly help me.

Regards

Date Subject Author
1/24/14 Narayanan
1/24/14 dpb
1/24/14 dpb
1/25/14 Narayanan
1/25/14 Bernt Nilsson
1/26/14 Narayanan
1/30/14 Narayanan
1/25/14 Ranjan Kumar