How to write a script

2 次查看(过去 30 天)
Riri
Riri 2014-1-19
编辑: Riri 2014-1-23
Write a matrix and ask for information

采纳的回答

Amit
Amit 2014-1-19
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
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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by