Matlab responds with 'busy'

3 Ansichten (letzte 30 Tage)
Ben Hatrick
Ben Hatrick am 10 Feb. 2021
Bearbeitet: Ben Hatrick am 10 Feb. 2021
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

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 10 Feb. 2021
Bearbeitet: Walter Roberson am 10 Feb. 2021
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 Kommentar
Ben Hatrick
Ben Hatrick am 10 Feb. 2021
Thank you so much, massive help!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by