line doesnt appear on my graph

t=0;
for i=10:-1:4 ;
z=i-1;
A0=pi*(i/2)^2;
Ai=pi*(z/2)^2;
phi=log(A0/Ai);
t=t+phi;
if i>=4
mu=0.05;
elseif i<4
mu=0.02;
end
F=A0*t*mu*80;
hold on
plot(i,F,'--ro')
title('force-stage number graph')
xlabel('Passes(mm)')
ylabel('Force[N]')
hold off
end

3 Comments

John D'Errico
John D'Errico on 26 Dec 2016
Edited: John D'Errico on 26 Dec 2016
Please don't post additional questions just to add something to your first question. I've moved your pic to a comment, THIS time.
Okay, i'll do it next time. I m sorry this is my first question in mathworks so i dont know how should i ask. Sorry again. THANK YOU

Sign in to comment.

 Accepted Answer

Try this:
t=0;
index = 1;
for i=10:-1:4
z=i-1;
A0=pi*(i/2)^2;
Ai=pi*(z/2)^2;
phi=log(A0/Ai);
t=t+phi;
if i>=4
mu=0.05;
elseif i<4
mu=0.02;
end
F(index) = A0*t*mu*80;
index = index + 1;
end
x = 10:-1:4;
hold on
plot(x, F, '--ro', 'LineWidth', 2)
grid on;
fontSize = 20;
title('Force-stage number graph', 'FontSize', fontSize)
xlabel('Passes [mm]', 'FontSize', fontSize)
ylabel('Force [N]', 'FontSize', fontSize)
hold off

More Answers (2)

John D'Errico
John D'Errico on 26 Dec 2016
Why do you expect a line to appear, since you are plotting those points ONE at a time? s far as MATLAB is concerned, you are plotting a set of distinct curves, each of which has only one point. So no line.
Create the entire vector of values first, THEN plot it in one call.
Stephen23
Stephen23 on 26 Dec 2016
Edited: Stephen23 on 26 Dec 2016
There is no point in the ugly loop when a fully vectorized solution is simpler, neater, and easier:
vec = 10:-1:4;
A0V = pi*((vec-0)/2).^2;
A1V = pi*((vec-1)/2).^2;
phi = log(A0V./A1V);
tV = cumsum(phi);
muV = 0.05 * ones(size(vec));
FV = A0V.*tV.*muV.*80
plot(vec,FV,'--ro')
title('force-stage number graph')
xlabel('Passes(mm)')
ylabel('Force[N]')

Categories

Find more on Graphics Performance in Help Center and File Exchange

Products

Tags

Asked:

on 26 Dec 2016

Edited:

on 26 Dec 2016

Community Treasure Hunt

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

Start Hunting!