How to update the value of the variable

1 visualización (últimos 30 días)
Mohamed Mahmoud
Mohamed Mahmoud el 25 de Oct. de 2020
Respondida: drummer el 25 de Oct. de 2020
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

Respuestas (1)

drummer
drummer el 25 de Oct. de 2020
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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by