Info
This question is closed. Reopen it to edit or answer.
v(t) is not defined help me!
1 view (last 30 days)
Show older comments
m=70
g=10
c=10
t=0;
v(0)=0;
while t<7*log(100)
t=t+0.1
v(t+1)= v(t)+0.1*(g-((c/m)*v(t)));
end
but the error is happened
how can i change v(0)=0;
1 Comment
Answers (1)
Rik
on 18 Mar 2019
Edited: Rik
on 18 Mar 2019
This code should work:
m=70;
g=10;
c=10;
t=0;
v=0;n=0;
while t<7*log(100)
t=t+0.1;
n=n+1;
v(n+1)= v(n)+0.1*(g-((c/m)*v(n)));
end
%OR:
m=70;
g=10;
c=10;
t=0:0.1:7*log(100);
v=zeros(size(t));
for n=2:numel(t)
v(n)=v(n-1)+0.1*(g-((c/m)*v(n-1)));
end
plot(t,v)
9 Comments
Walter Roberson
on 18 Mar 2019
Yes, but the exp() form you posted is not anywhere close to the actual solution.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!