reshape loop resulted cell array

조회 수: 1 (최근 30일)
Oday Shahadh
Oday Shahadh 2020년 6월 19일
댓글: Oday Shahadh 2020년 6월 19일
hi, the script below is supposed to result a (n,3) vector, what I got is (180,60) vector, kindley help
c1 = cell(numel(a11),1);
for ii = 1:length(L1);
for kk = 1:length(a11);
c1{ii,kk}=cross(L1(ii,:),a11(kk,:));
end
end
  댓글 수: 2
James Tursa
James Tursa 2020년 6월 19일
It is unclear what you really want as an answer. The current code creates a cell array of all possible combinations of cross products of vectors from L1 and a11. This is what you want? But you want the result to be a matrix that is n x 3 instead of a cell array?
Oday Shahadh
Oday Shahadh 2020년 6월 19일
yes james, because furthe I need to quiver3 the resulted data

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

채택된 답변

James Tursa
James Tursa 2020년 6월 19일
result = cell2mat(c1(:))';
  댓글 수: 3
James Tursa
James Tursa 2020년 6월 19일
Pre-allocate differently:
c1 = cell(length(L1),length(a11));
Oday Shahadh
Oday Shahadh 2020년 6월 19일
Thanks

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by