필터 지우기
필터 지우기

couldnt able to use switch statement with string

조회 수: 2 (최근 30일)
AJAY CHANDRA DORAGARI
AJAY CHANDRA DORAGARI 2020년 6월 26일
답변: Fangjun Jiang 2020년 6월 26일
w=input('enter the weight ')
material=input('enter type of material ','s');
material=lower('material');
f1=0.2*w;
f2=0.35*w;
f3=0.4*w;
f4=0.7*w;
switch material
case 'mmetal'
disp(f1)
case 'wwood'
disp(f2)
case 'mwood'
disp(f3)
case 'rcon'
disp(f4)
otherwise
disp('error')
end
it is jumping to otherwise line
and can we use mathematical operation and display that result under 'case' section
i.e for example
case mm
force =w*0.3

채택된 답변

Fangjun Jiang
Fangjun Jiang 2020년 6월 26일
material=lower(material); without the single quote.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Modeling에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by