### Tags: code, doit, generate, increment, index, loop, matlab, matrix, multiplematrix, programming, value, variable, write

# Variable matrix in loop

On Programmer » Matlab

3,066 words with 2 Comments; publish: Tue, 06 May 2008 17:27:00 GMT; (20092.77, « »)

I want to write a code in which, I want to generate the multiple

matrix [n x2] of same name, with increment index value. I want to do

it in loop, I am trying to do it, but unable to write a code for

this.

for a=1:1:itra,

for i=1:z-1,

if input_points2(i,1)>=x(1) & ...

input_points2(i,1)<=x(2) &...

input_points2(i,2)>=y(1) &...

input_points2(i,2)<=y(3);

edgetop(tz,1) = input_points2(i,1); %this matrix

should me incremental matrix

edgetop(tz,2) = input_points2(i,2); %this matrix should

me incremental matrix

tz = tz+1;

end

end

end

How can I write the loop code to do that.

If any know this please do let me know.

Regards,

Sohaib.

*http://matlab.todaysummary.com/q_matlab_62680.html*

All Comments

Leave a comment...

- 2 Comments
- Sohaib Khan wrote:
> I want to write a code in which, I want to generate the multiple

> matrix [n x2] of same name, with increment index value. I want to do

> it in loop, I am trying to do it, but unable to write a code for

> this.

> for a=1:1:itra,

> for i=1:z-1,

> if input_points2(i,1)>=x(1) & ...

> input_points2(i,1)<=x(2) &...

> input_points2(i,2)>=y(1) &...

> input_points2(i,2)<=y(3);

> edgetop(tz,1) = input_points2(i,1); %this matrix

> should me incremental matrix

> edgetop(tz,2) = input_points2(i,2); %this matrix should

> me incremental matrix

> tz = tz+1;

> end

> end

> end

> How can I write the loop code to do that.

What problem are you having?

Except for the fact that tz is not initialized (set

to 1) before starting, this seems to be OK.

It will generate a matrix edgetop consisting of

all rows of input_points2 which meet the specified

condition.

I don't understand the loop over a=1:itra, since

everything seems to be the same for every value of

a.

- Randy

#1; Tue, 06 May 2008 17:28:00 GMT

- Sohaib Khan wrote:
- My mistake not to write in email, tz is already initialised to 1. Let
me clear the requirement bit more that i want two sperate set of

edgetop of matrix [nx2] size (the xy cordinate), while itra is a

number given by the user, that how many subsample it want out of

existing whole edgetop matrix which is very large in size [12000x2]

matrix, while X(1) & x(2) are x limites, similary y(1) & y(2) are y

limit, ask by use graphically.

Just i need to have different set of edgetop matrix for each x & y

upper & lower limit.

Regards,

Sohaib.

Randy Poe wrote:

>

> Sohaib Khan wrote:

multiple

to

> do

for

> should

> What problem are you having?

> Except for the fact that tz is not initialized (set

> to 1) before starting, this seems to be OK.

> It will generate a matrix edgetop consisting of

> all rows of input_points2 which meet the specified

> condition.

> I don't understand the loop over a=1:itra, since

> everything seems to be the same for every value of

> a.

> - Randy

>

#2; Tue, 06 May 2008 17:29:00 GMT

- My mistake not to write in email, tz is already initialised to 1. Let