What is the best way to append double arrays while working in a loop?

조회 수: 60 (최근 30일)
Tobias Schwarz
Tobias Schwarz 2021년 3월 11일
답변: Seth Furman 2021년 3월 22일
Hello,
i want to append double arrays to a table/struct to work with them afterwards, e.g. for plotting.
What is the best way to do this and how?
Double arrays look like following:
Thank you very much in advance!

답변 (2개)

Deepak Meena
Deepak Meena 2021년 3월 16일
Hi Tobias,
My understanding is that you want to concatenate the double array to a struct/table and by "double array" you mean array having the double type values.
For struct you can do this :
>> s = struct;
>> t = linspace(3,5,20);
>> s = setfield(s,"FieldName",t);
  댓글 수: 1
Tobias Schwarz
Tobias Schwarz 2021년 3월 17일
Yes thank you, thats it. How can i append the double arrays into this struct while getting generated in a loop?

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


Seth Furman
Seth Furman 2021년 3월 22일
You can append values to a table using concatenation as follows
>> t = table(1,2)
t =
1×2 table
Var1 Var2
____ ____
1 2
>> t2 = [t;table(3,4)]
t2 =
2×2 table
Var1 Var2
____ ____
1 2
3 4
>> t2 = [t;{3,4}]
t2 =
2×2 table
Var1 Var2
____ ____
1 2
3 4

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by