Info

この質問は閉じられています。 編集または回答するには再度開いてください。

v(t) is not defined help me!

1 回表示 (過去 30 日間)
Jeong Mo Son
Jeong Mo Son 2019 年 3 月 18 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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 件のコメント
Rik
Rik 2019 年 3 月 18 日
You are confusing indexing with a function call.

回答 (1 件)

Rik
Rik 2019 年 3 月 18 日
編集済み: Rik 2019 年 3 月 18 日
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 件のコメント
Star Strider
Star Strider 2019 年 3 月 18 日
@Walter —
I was responding to Rik’s earlier Comment (link).
Walter Roberson
Walter Roberson 2019 年 3 月 18 日
Yes, but the exp() form you posted is not anywhere close to the actual solution.

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by