Borrar filtros
Borrar filtros

Switch case

2 visualizaciones (últimos 30 días)
zina ben
zina ben el 14 de Feb. de 2012
Editada: Matt J el 13 de Oct. de 2013
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

Respuesta aceptada

Sean de Wolski
Sean de Wolski el 14 de Feb. de 2012
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 comentario
Walter Roberson
Walter Roberson el 15 de Feb. de 2012
Note the code for 'second' should divide the sin() result by 2 to match the original question.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Array Geometries and Analysis en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by