Assign multiple results to the same variable

I'm doing a code that uses while, and inside that while is a variable whose value gets changed every instance, I want to store all those values on a single variable to table it later, how can I do that?

3 件のコメント

Mathieu NOE
Mathieu NOE 2023 年 8 月 31 日
indexing the varoable is the solution
k = 0;
while ....
k = k+1;
data(k) = ...
end
Chesus
Chesus 2023 年 8 月 31 日
Thanks a lot, I didnt understand it at first but it ended up helping me

サインインしてコメントする。

 採用された回答

Chesus
Chesus 2023 年 8 月 31 日

0 投票

indexing the varoable is the solution

if true
  % code
k=0
while ... %the condition you decide
k=k+1 %by experience k must be >0, idk why
data(k)=...%you can change the word "data", after the equal must be the value you want to store, then you can call this values as the variable "data"
end
end

Answer originally posted by Mathieu NOE

その他の回答 (0 件)

カテゴリ

製品

リリース

R2022b

質問済み:

2023 年 8 月 31 日

回答済み:

2023 年 8 月 31 日

Community Treasure Hunt

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

Start Hunting!

Translated by