Matlab responds with 'busy'

3 visualizzazioni (ultimi 30 giorni)
Ben Hatrick
Ben Hatrick il 10 Feb 2021
Modificato: Ben Hatrick il 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

Risposta accettata

Walter Roberson
Walter Roberson il 10 Feb 2021
Modificato: Walter Roberson il 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

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by