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

1 Ansicht (letzte 30 Tage)
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)

Akzeptierte Antwort

Stephen23
Stephen23 am 28 Apr. 2021
Bearbeitet: Stephen23 am 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
>>

Weitere Antworten (0)

Kategorien

Mehr zu Simulink 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