Borrar filtros
Borrar filtros

How to write a script

4 visualizaciones (últimos 30 días)
Riri
Riri el 19 de En. de 2014
Editada: Riri el 23 de En. de 2014
Write a matrix and ask for information

Respuesta aceptada

Amit
Amit el 19 de En. de 2014
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

Más respuestas (1)

Riri
Riri el 19 de En. de 2014
Editada: Riri el 19 de En. de 2014
Yeah I think it would be something like this. I will try it. Thanks a lot
  1 comentario
Amit
Amit el 19 de En. de 2014
switch is similar to multiple if-elseif-elseif

Iniciar sesión para comentar.

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by