필터 지우기
필터 지우기

convert an array to a new

조회 수: 2 (최근 30일)
babis
babis 2013년 10월 12일
댓글: Azzi Abdelmalek 2013년 10월 12일
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?

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 10월 12일
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
Azzi Abdelmalek
Azzi Abdelmalek 2013년 10월 12일
Babis commented
Very helpful! thanks.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by