For loop store variable with different dimension

조회 수: 10(최근 30일)
Hi all,
I have a question about storing the results from a for loop. The problem is that each round results in a vector of different size. I thought creating an cell should work, but I'm clearly (doing something) wrong. Other option, maybe? would be to fill the "empty" places in the matrix with zeros.

채택된 답변

Von Duesenberg
Von Duesenberg 2018년 3월 17일
A cell should work fine:
C = cell(2,1);
C{1} = [1 2 3];
C{2} = [1 2 3 4];
  댓글 수: 1
Rick Verberne
Rick Verberne 2018년 3월 19일
Thank you, it works indeed. I was mixing the type of brackets to used.

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

추가 답변(0개)


Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by