필터 지우기
필터 지우기

Problem padding a 3d array

조회 수: 5 (최근 30일)
James Murphy
James Murphy 2018년 2월 28일
답변: James Murphy 2018년 2월 28일
Hi I have a nested structure of 25 structures of 1x1 stuct, the 1x1 struct contains an array of Nx3 double values that I wish to store in an array of Nx3x25. So there are 25 segments of varying length (194-200). The code below fills the array contours with the minimum 194x4x25. I set d to the max N=200.
contours=zeros(d,3,25);
for i = 1:25
contours(:,:,k)=c(k).segments.points;
end
I have tried various ways of padding but can't seem to get any to work. I hope this is enough information. Any ideas please? James

채택된 답변

James Murphy
James Murphy 2018년 2월 28일
I cracked it eventually, it did not help that I had a k instead of the i as the index.
for i = 1:25
s=size(c(i).segments.points,1);
contours(:,:,i)=padarray(c(i).segments.points, [(d-s),0],0,'post');
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by