how can i change the columns in the matrix? For example I wanna change 2nd and 3rd column

M = [1 2 3 4; ...
2 4 6 8; ...
3 6 9 12];

3 comentarios

Jan
Jan el 9 de En. de 2013
Editada: Jan el 9 de En. de 2013
I've brushed up your text a little bit.
Does "change" mean changing the values or interchanging the columns itself?
If you mean interchange, as Jan pointed out, you can something like this. say M has 3 columns:
M=M(:,[1 3 2]);
Check help for indexing matrices.
How about you change them both to zeros? Next time, give an example of what you want your output to be so people won't have to guess.

Iniciar sesión para comentar.

 Respuesta aceptada

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Preguntada:

el 9 de En. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by