2 views (last 30 days)

when i run this code i have the plot screen appear but no data on it. can anbody help me please?

f = 1:0.1:1;

h = 0:0.1:4;

for i=1:length(f)

for j=1:length(h)

t=0;

L = 1;

m = 7+L;

u = 0.042;

Um = h(i) * (f(i));

r = Um * -cos(f(i) * t);

dy = Um*r(i)*sin(f(i)*t);

df = 1+L;

p = ((df * u)/m) * Um;

B = (df * (u^2) * f(i))/(2 * pi * m);

a = p/B;

g = 1 + ((pi * B)^(-0.5));

c = df*u^2;

Cd = (pi*B)^(-0.5);

n = r*abs(r)*u*Cd;

e=((c + n));

plot(f,e(i),'Linewidth',1.5);

hold on

xlabel('x');

ylabel('y');

end

end

Alan Stevens
on 13 Aug 2020

hosein Javan
on 13 Aug 2020

"f" was scalar rather than vector. some constants needed to be defined outside of the loop. and the iteration-depandant variables are fixed. I just don't know what is the inner loop for. you need to clarify what you want.

f = 0:0.1:1;

h = 0:0.1:4;

t=0;

L = 1;

m = 7+L;

u = 0.042;

df = 1+L;

c = df*u^2;

for i=1:length(f)

for j=1:length(h)

Um(i) = h(i) * (f(i));

r(i) = Um(i) * -cos(f(i) * t);

dy(i) = Um(i)*r(i)*sin(f(i)*t);

p(i) = ((df * u)/m) * Um(i);

B(i) = (df * (u^2) * f(i))/(2 * pi * m);

a(i) = p(i)/B(i);

g(i) = 1 + ((pi * B(i))^(-0.5));

Cd(i) = (pi*B(i))^(-0.5);

n(i) = r(i)*abs(r(i))*u*Cd(i);

e(i) = ((c + n(i)));

end

end

plot(f,e,'Linewidth',1.5);

xlabel('x');

ylabel('y');

Opportunities for recent engineering grads.

Apply TodayFind the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
## 1 Comment

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/579126-no-plot-appearing-for-loop#comment_971028

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/579126-no-plot-appearing-for-loop#comment_971028

Sign in to comment.