Asked by Kaleesh Bala
on 18 Feb 2019

The value of j goes upto 1025 but i stays at 255 itself ,what's the error in this nested loop??

X = load('x.mat');

Y = load('y.mat');

for i=245:61503

i = i+10;

for j=1:1024

j=j+1;

figure(); hold on

plot(Y.y(1:i,j))

set(0,'DefaultFigureWindowStyle','docked')

end

end

hold off

Answer by ibabinaca
on 18 Feb 2019

Edited by ibabinaca
on 18 Feb 2019

Accepted Answer

Why are you putting j = j+1? There is no need to put it with matlab.

X = load('x.mat');

Y = load('y.mat');

for i=245:10:61503

for j=1:1024

figure(); hold on

plot(Y.y(1:i,j))

set(0,'DefaultFigureWindowStyle','docked')

end

end

hold off

By the way, 245+10*n is never going to be 61503

Rik
on 18 Feb 2019

Kaleesh Bala
on 18 Feb 2019

Alright you're right , for i=247:10:61503 this goes to 61503.

Could you lemme know how can I convert it to 3D values and the plot a surf out of it?

Kaleesh Bala
on 20 Feb 2019

Alright matlab crashes for sure :) due to rendering issues.

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 5 Comments

## Rik (view profile)

## Direct link to this comment

https://de.mathworks.com/matlabcentral/answers/445541-value-of-a-variable-not-changing-in-the-workspace#comment_672431

## Kaleesh Bala (view profile)

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/445541-value-of-a-variable-not-changing-in-the-workspace#comment_672435

## Kaleesh Bala (view profile)

## Direct link to this comment

https://de.mathworks.com/matlabcentral/answers/445541-value-of-a-variable-not-changing-in-the-workspace#comment_672441

## Rik (view profile)

## Direct link to this comment

https://de.mathworks.com/matlabcentral/answers/445541-value-of-a-variable-not-changing-in-the-workspace#comment_672444

## Kaleesh Bala (view profile)

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/445541-value-of-a-variable-not-changing-in-the-workspace#comment_672448

Sign in to comment.