how can i create only the Matrix index
    3 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    mohammed hussein
 el 7 de Nov. de 2017
  
    
    
    
    
    Comentada: mohammed hussein
 el 7 de Nov. de 2017
            Hi i would like to create two variable that represent the matrix index of any size of matrix for example if i have matrix
A=[(1,1) (1,2) (1,3);(2,1) (2,2) (2,3);(3,1) (3,2) (3,3)]
how can i create like the matrix A
thank you
0 comentarios
Respuesta aceptada
  Walter Roberson
      
      
 el 7 de Nov. de 2017
        The easiest way is
sparse(list_of_row_indices, list_of_corresponding_column_indices, list_of_corresponding_values)
You can full() the result afterwards.
3 comentarios
  Walter Roberson
      
      
 el 7 de Nov. de 2017
				[R,C] = ndgrid(1:size(YourMatrix,1), 1:size(YourMatrix,2));
A = idxMatrix = arrayfun(@(r,c) [r,c], R, C, 'uniform', 0);
Más respuestas (0)
Ver también
Categorías
				Más información sobre Matrix Indexing en Help Center y File Exchange.
			
	Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

