フィルターのクリア

How can ı choose a defined valuable when ı use input function

1 回表示 (過去 30 日間)
Ugur Sahin
Ugur Sahin 2020 年 2 月 15 日
コメント済み: Ugur Sahin 2020 年 2 月 15 日
Hi Guys,
I have a homework I have to use valuable that ı defined with numbers like A=0.5..C= 0.3. Users can choose these variable when ı ask to user that vehiclename=input('please enter the veicle name such as A,B,C). If user respond C, the vehiclename will change to value of the C like 0.3.
VehicleName = input('please enter the vehicle name');
if if VehicleName= A || a;
VehicleName = 0.5;
elseif VehicleName= B || b;
VehicleName= 0.4;
elseif VehicleName= C || c
VehicleName= 0.3;
end
You see what ı can do please could you help me ?

採用された回答

Stephen23
Stephen23 2020 年 2 月 15 日
vn = input('please enter the vehicle name ','s');
switch upper(vn)
case 'A'
val = 0.5;
case 'B'
val = 0.4;
case 'C'
val = 0.3;
otherwise
error('this vehicle type is unknown')
end
  1 件のコメント
Ugur Sahin
Ugur Sahin 2020 年 2 月 15 日
Thank you so much I have done with your help :D

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeVehicle Network Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by