필터 지우기
필터 지우기

Switch case

조회 수: 2 (최근 30일)
zina ben
zina ben 2012년 2월 14일
편집: Matt J 2013년 10월 13일
Hi, I have two methods for calculate xg
The first one is t=1:0.1:10 xg=sin(t)
The second one is t=1:0.2:10 xg=sin (t)/2
I need to write 1, I have the result of the first method and if, I write 2 I have the result of the second method
Please can used the 'Switch case' in this case, if yes can you tell me how Please, i need your help thinks in advance

채택된 답변

Sean de Wolski
Sean de Wolski 2012년 2월 14일
val = 'first';
switch val
case 'first'
xg = sin(0:0.1:10);
case 'second'
xg = sin(0:0.2:10);
otherwise
doc switch
end
  댓글 수: 1
Walter Roberson
Walter Roberson 2012년 2월 15일
Note the code for 'second' should divide the sin() result by 2 to match the original question.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Array Geometries and Analysis에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by