Hello guys my code works fine but even though i add '--r' in my plot there is no line connecting them.
this is my code
g=9.8;
fc=0;
c=0;
m=68.1;
v=40;
t=10;
row=1;
A(1,1) = {'C'};
A(1,2) = {'f(C)'};
for c=0:2:20
row = row+1;
aprev=fc;
fc = (g*m*(1-(exp((-c*t)/m)))/c)-v;
A(row,1) = {c};
A(row,2) = {fc};
plot(c,fc,'-*b')
grid on
hold on
end
disp(A);

Answers (1)

DGM
DGM on 22 Mar 2021
To just address the plotting issue, bear in mind that what you're doing is plotting each point individually. It doesn't draw a line between them since as far as plot() knows, they don't belong to the same series.
g=9.8;
fc=0;
c=0;
m=68.1;
v=40;
t=10;
row=1;
A(1,1) = {'C'};
A(1,2) = {'f(C)'};
for c=0:2:20
row = row+1;
prev=fc;
fc = (g*m*(1-(exp((-c*t)/m)))/c)-v;
A(row,1) = {c};
A(row,2) = {fc};
end
justthedata=cell2mat(A(2:end,:));
plot(justthedata(:,1),justthedata(:,2),'-*b')
grid on
disp(A);
Moving the plot() call outside the loop works.

Categories

Asked:

on 22 Mar 2021

Edited:

on 22 Mar 2021

Community Treasure Hunt

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

Start Hunting!