How to update the value of the variable

1 回表示 (過去 30 日間)
Mohamed Mahmoud
Mohamed Mahmoud 2020 年 10 月 25 日
回答済み: drummer 2020 年 10 月 25 日
clear
clc
syms forced velocityd densityd density dynamicviscosityd accelerationd Diameterd viscosityd Lengthd pressured a b c d y S Q x f Lenght forced velocity density dynamic_viscosity acceleration Diameter viscosity S1 S2 S z z1 z2 pressure %variables
syms M L T temp
repeating_v1 = input('What do u want to know');
temp=repeating_v1;
density=66;
repeating_v1;
disp("Your" + temp+ "is"+ repeating_v1 )
I want the answer to be
Your density is 66 if the input was density

回答 (1 件)

drummer
drummer 2020 年 10 月 25 日
Try this workaround
clear
clc
syms forced velocityd densityd density dynamicviscosityd accelerationd Diameterd viscosityd Lengthd pressured a b c d y S Q x f Lenght forced velocity density dynamic_viscosity acceleration Diameter viscosity S1 S2 S z z1 z2 pressure %variables
syms M L T temp
repeating_v1 = input('What do u want to know: \n');
temp=repeating_v1;
density=66;
if repeating_v1 == 'density' % Your condition: if input is density
X = ['Your ' char(repeating_v1) ' is ' num2str(density)];
disp(X);
end
Cheers

カテゴリ

Help Center および File ExchangeFormula Manipulation and Simplification についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by