Borrar filtros
Borrar filtros

changing value in a 2d array

61 visualizaciones (últimos 30 días)
charlie
charlie el 11 de Jul. de 2011
hi, thank you for your help.
I would like to know how to change values in a 2d array. For example, I have an 2d array A as of 1000x1000, of all zero values
I want to change value in position, 1x1, 1x100, 1x1000 to value 1.
do you know a quick way of doing this?

Respuesta aceptada

Rick Rosson
Rick Rosson el 11 de Jul. de 2011
Please try the following:
A(1,1) = 1;
A(1,100) = 1;
A(1,1000) = 1;
HTH.
  1 comentario
charlie
charlie el 11 de Jul. de 2011
please see my response below, many thanks

Iniciar sesión para comentar.

Más respuestas (2)

Walter Roberson
Walter Roberson el 11 de Jul. de 2011
A(1,[1 100 1000]) = 1;
  1 comentario
charlie
charlie el 11 de Jul. de 2011
please see my response below, many thanks

Iniciar sesión para comentar.


charlie
charlie el 11 de Jul. de 2011
thank you guys, when everytime i run the above function, Matlab automatically loop through the entire 1000x1000 array. as the following:
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
I dont have any for loop in there, and this took a lot of time to compelete the entire program, do you have any ideas?
  4 comentarios
bym
bym el 12 de Jul. de 2011
agree with Oleg, just didn't post soon enough!
charlie
charlie el 12 de Jul. de 2011
thank you very much, you guys are awsome

Iniciar sesión para comentar.

Categorías

Más información sobre Loops and Conditional Statements 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