When running the following code no output (graph) is given, instead matlab gives 'busy' in the bottem left hand corner. Any ideas?
if (x<=-d)
a = -g -s1*x/m_c -v*c/m_c + s2*x/m_c;
else a = -g -s1*x/m_c -v*c/m_c;
end
x = x + v*dt;
v = v + a*dt;
Disp(i)=x;
Vel(i)=v;
t=t+dt;
Time(i)=t;
i=i+1;
end
end

 採用された回答

Walter Roberson
Walter Roberson 2021 年 2 月 10 日
編集済み: Walter Roberson 2021 年 2 月 10 日

0 投票

if (x<=-d)
when that is true, you do not change t, and you get caught in an infinite loop.
Perhaps you want an "end" immediately after the second assignment
if (x<=-d)
a = -g -s1*x/m_c -v*c/m_c + s2*x/m_c;
else
a = -g -s1*x/m_c -v*c/m_c;
end

1 件のコメント

Ben Hatrick
Ben Hatrick 2021 年 2 月 10 日
Thank you so much, massive help!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

質問済み:

2021 年 2 月 10 日

編集済み:

2021 年 2 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by