How to store vectores which have different lengts? (in a loop)
조회 수: 1 (최근 30일)
이전 댓글 표시
This doesnt work because every tupple have differents lengths :
for i=2:5
ar(i,:)=ones(1,q(i)-q(i-1)+2);
end
q is a random generated vector here.
What I intended to do is:
ar(2,:)=ones(1,q(2)-q(1)+2)
ar(3,:)=ones(1,q(3)-q(2)+2)
.
.
.
댓글 수: 0
채택된 답변
madhan ravi
2018년 12월 13일
Store it as cell like below:
ar=cell(1,4);
for i=2:5
ar{i-1}=ones(1,q(i)-q(i-1)+2);
end
celldisp(ar)
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!