How to update the value of the variable

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Formula Manipulation and Simplification 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by