Borrar filtros
Borrar filtros

convert an array to a new

2 visualizaciones (últimos 30 días)
babis
babis el 12 de Oct. de 2013
Comentada: Azzi Abdelmalek el 12 de Oct. de 2013
I have an array M [100000*3]. I want to create a new array where the one dimension will be the 1st column of the array M, the 2nd dimension will be the second column and the values of this new array will be taken from the third column. Some values of the new array will be zero/null. how do i convert the original array to new?

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 12 de Oct. de 2013
c1=M(:,1)
c2=M(:,2)
n=max(c1);
m=max(c2);
idx=sub2ind([n m],c1,c2)
out=zeros(n,m);
out(idx)=M(:,3)
  1 comentario
Azzi Abdelmalek
Azzi Abdelmalek el 12 de Oct. de 2013
Babis commented
Very helpful! thanks.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays 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