How can I use inputdlg() to store multiple variables and then use those variables in equations for later?

1 visualizzazione (ultimi 30 giorni)
Variables = inputdlg(["m","b","k","x1","x2","F","w0"])
Values = str2double(Variables{:})
l = b/2
w = sqrt(k/m)
wc=sqrt(w^2-l^2)
r1=-l+sqrt(l^2-w^2)
r2=-l-sqrt(l^2-w^2)

Risposta accettata

Stephen23
Stephen23 il 28 Apr 2021
Modificato: Stephen23 il 28 Apr 2021
>> C = inputdlg(["m","b","k","x1","x2","F","w0"])
C =
7×1 cell array
{'1.2'}
{'2.3'}
{'3.4'}
{'4.5'}
{'5.6'}
{'6.7'}
{'7.8'}
>> C = num2cell(str2double(C));
>> [m,b,k,x1,x2,F,w0] = deal(C{:})
m =
1.2000
b =
2.3000
k =
3.4000
x1 =
4.5000
x2 =
5.6000
F =
6.7000
w0 =
7.8000
>>

Più risposte (0)

Categorie

Scopri di più su Simulink 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