I think I need a for loop,
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Mohammad Reza Javadzadegan
el 7 de Feb. de 2023
Editada: Mohammad Reza Javadzadegan
el 8 de Abr. de 2023
I need a Variable like x to have 3 different values and matlab to calculate the whole code based on those 3 values simultaneously. then I need another variable to have 3 different values, so I will have 9 different answers based on that change. but I need matlab to give me a matrix as (9,1)..any helps?
0 comentarios
Respuestas (1)
John D'Errico
el 7 de Feb. de 2023
Editada: John D'Errico
el 7 de Feb. de 2023
[x,y] = meshgrid(1:3,[2 3 5])
z = x+y
If you need it as a 9x1 array, then just unroll the arrays into vectors.
z = z(:)
Start to learn how to use MATLAB as it is designed to be used, instead of writing everything as a loop.
0 comentarios
Ver también
Categorías
Más información sobre Loops and Conditional Statements 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!