Matlab responds with 'busy'

3 次查看(过去 30 天)
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
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by