フィルターのクリア

Creating structure array that accumulates

2 ビュー (過去 30 日間)
amateurintraining
amateurintraining 2017 年 10 月 3 日
編集済み: Cedric 2017 年 10 月 3 日
How do you create a structure array such that the structure array has five fields that are initially empty then more entries are entered to make the structure array a 1x2 structure? For example, the array has fields: field1, field2, field3, field4, field5. And the first entry is empty. The next command adds another entry with value1,value2,value3,value4,and value5. Basically, the following entries will result in an accumulation of entries. I want to create a function that builds on itself.
Preferably, I would like to see how this is done without if-else statements.
Thank you in advance!
  1 件のコメント
Cedric
Cedric 2017 年 10 月 3 日
編集済み: Cedric 2017 年 10 月 3 日
You could just pay attention to the answers that were already given to you, e.g. here where I spent time carefully explaining a couple approaches to you:
and then here for the same question later:
where you can see in the comments under your question that both James and I are wondering why you didn't pay attention to the first answer.

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

回答 (1 件)

KSSV
KSSV 2017 年 10 月 3 日
S = struct ;
% marks in three subjects
S.Maths= [];
S.Physics = [] ;
S.Chemsitry = [] ;
%%five students marks
for i = 1:5
S(i).Maths= rand*100;
S(i).Physics = rand*100 ;
S(i).Chemsitry = rand*100 ;
end

カテゴリ

Help Center および File ExchangeData Types についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by