Got Questions? Get Answers.
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:
How I store a vector in for loop?

Subject: How I store a vector in for loop?

From: karina.neves@vivo.net.br (Karina Neves)

Date: 31 Jan, 2005 21:06:11

Message: 1 of 1

I've found the answer, and that's so simple that I am embarrassed of
having asked. It's just to put the SR inside SR, like sr=[sr,st,r];
right? Thank you all. very much

On 31 Jan 05 15:02:03 -0500 (EST), Karina Neves wrote:
>I am doing
>function SR=S(I)
>I= [16 0 2 13; 0 0 -11 8; 9 6 7 0; 4 15 0 1];% matrix example
>zeros = 0;
>for z = I(1:16) %I don'nt know how to put it like for z= I(a11:aij)
> if z == 0 %if the elemente is equal zero
> zeros = zeros + 1; % add one in zeros
> else
> st = z; %else reads the element
> r = zeros; %reads the amount of zeros
> SR=[st,r] % stores the values in a vector
> zeros = 0;
> end
>end
>the problem is that the vector SR doesn't keep all the values, it
just
>saves the last one, could anyone help me? I know it's dumb, but I
>don't know how to solve it! Thanks.

Tags for this Thread

No tags are associated with 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