Make matlab save results to the same table but different rows

조회 수: 2 (최근 30일)
Thor
Thor 2021년 5월 4일
댓글: Thor 2021년 5월 14일
Hi I got a while loop that calculates the size of a vector for several columns of data. I was wondering if there is a method to save all the outputs to one table in different rows. Many thanks in advance.

채택된 답변

Adam Danz
Adam Danz 2021년 5월 4일
I would store the values within the while loop and then convert the array to a table using array2table.
rng('default')
x = [];
z = rand();
while z > .01
x(end+1) = z;
z = rand();
end
T = array2table(x(:),'VariableName',{'myVar'})
T = 122×1 table
myVar _______ 0.81472 0.90579 0.12699 0.91338 0.63236 0.09754 0.2785 0.54688 0.95751 0.96489 0.15761 0.97059 0.95717 0.48538 0.80028 0.14189
  댓글 수: 6
Adam Danz
Adam Danz 2021년 5월 4일
Sure, include only the relevant sections, describe the size of your data, and share any error messages you're getting.
Thor
Thor 2021년 5월 14일
I figured it out after changing the names of my variables. Thanks a lot for the examples.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by