필터 지우기
필터 지우기

Combine two vectors a make a Matrix

조회 수: 2 (최근 30일)
pankaj singh
pankaj singh 2020년 11월 30일
댓글: Ameer Hamza 2020년 12월 1일
Hello~
I have two 1158 x 1 vectors. First one is 'rown' and second one 'coln'. I want to create a 'new' matrix using both vectors. Coln matrix shares the column numbers of the new matrix. The new matrix must of size 10 x 256 such that the it has the same values as found in rown matrix. For example:
if coln(1,1)=1;
and rown(1,1)=118;
then, new_mat(1,1)=118.
Some values are missing in between that can be filled by 1s. Both vectors are attached above.
If you don't understand what I want, please check the image file.

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 11월 30일
Try this
C = accumarray(coln, rown, [], @(x) {[x; ones(10-numel(x),1)]}, {ones(10,1)});
M = [C{:}];
  댓글 수: 2
pankaj singh
pankaj singh 2020년 12월 1일
Thanks... it worked...
Ameer Hamza
Ameer Hamza 2020년 12월 1일
I am glad to be of help!

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by