Matlab responds with 'busy'

3 vues (au cours des 30 derniers jours)
Ben Hatrick
Ben Hatrick le 10 Fév 2021
Modifié(e) : Ben Hatrick le 10 Fév 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
  1 commentaire
Adam Danz
Adam Danz le 10 Fév 2021
Learn to use Debug Mode to quickly solve these types of issues.

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 10 Fév 2021
Modifié(e) : Walter Roberson le 10 Fév 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 commentaire
Ben Hatrick
Ben Hatrick le 10 Fév 2021
Thank you so much, massive help!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by