채택된 답변

Amit
Amit 2014년 1월 19일

0 개 추천

Something like this?
function myProg
myMat = input('Enter 4x4 Matrix\n');
Useropt = input('Row [1] Column [2] Single Element [3]\n');
switch Useropt
case 1
val = input('Which Row\n');
disp(myMat(val,:));
case 2
val = input('Which Column\n');
disp(myMat(:,val));
case 3
val1 = input('Which Row\n');
val2 = input('Which Column\n');
disp(myMat(val1,val2));
otherwise
disp('wrong input');
end
end

추가 답변 (1개)

Riri
Riri 2014년 1월 19일
편집: Riri 2014년 1월 19일

0 개 추천

Yeah I think it would be something like this. I will try it. Thanks a lot

댓글 수: 1

Amit
Amit 2014년 1월 19일
switch is similar to multiple if-elseif-elseif

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

카테고리

도움말 센터File Exchange에서 Vehicle Scenarios에 대해 자세히 알아보기

질문:

2014년 1월 19일

편집:

2014년 1월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by