How to update the value of the variable

1 Ansicht (letzte 30 Tage)
Mohamed Mahmoud
Mohamed Mahmoud am 25 Okt. 2020
Beantwortet: drummer am 25 Okt. 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

Antworten (1)

drummer
drummer am 25 Okt. 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

Community Treasure Hunt

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

Start Hunting!

Translated by