Info

This question is closed. Reopen it to edit or answer.

v(t) is not defined help me!

1 view (last 30 days)
Jeong Mo Son
Jeong Mo Son on 18 Mar 2019
Closed: MATLAB Answer Bot on 20 Aug 2021
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
Rik
Rik on 18 Mar 2019
You are confusing indexing with a function call.

Answers (1)

Rik
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
Star Strider
Star Strider on 18 Mar 2019
@Walter —
I was responding to Rik’s earlier Comment (link).
Walter Roberson
Walter Roberson on 18 Mar 2019
Yes, but the exp() form you posted is not anywhere close to the actual solution.

Tags

Community Treasure Hunt

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

Start Hunting!