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 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