Hello,
i have a stuct which holds 12 signals. The signals are represented by frequency, power and a vector for each of the signals as seen in the following picture:
I have another matrix of the signals which passed through some model as seen in the follwoing picture:
I would like to merge the struct with the matrix, so that the struct will hold another column/new field where each struct row corresponts to each matrix row. How can I do this w/o for loop?
Thanks!

 採用された回答

Matt J
Matt J 2021 年 7 月 21 日
編集済み: Matt J 2021 年 7 月 21 日

0 投票

You cannot avoid a for-loop altogether, but you can avoid writing your own for-loop as follows:
tmp=num2cell(modelOutputSignal,2); %num2cell has a for-loop inside it.
[yourStruct(1:numel(tmp)).newfield]=deal(tmp{:});

2 件のコメント

GSM
GSM 2021 年 7 月 22 日
Perfect ! Thanks a lot!
GSM
GSM 2021 年 7 月 22 日
Matt J ,
Another question.
When i have such struct:
How can I "cut" the 2 left columns "Inputrequency_MHz" and "InputPower_dBm" into some new struct?

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

その他の回答 (1 件)

Dhruv G
Dhruv G 2021 年 7 月 21 日

0 投票

say the structure is named s,
s.outputSignal = modelOutputSignal;
adds the matrix as an element to the structure. You can then reference a matrix element as s.outputSignal(rowNumber, columnNumber)

1 件のコメント

GSM
GSM 2021 年 7 月 22 日
I get the following error:
Scalar structure required for this assignment.

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

カテゴリ

ヘルプ センター および File ExchangeStructures についてさらに検索

質問済み:

GSM
2021 年 7 月 21 日

コメント済み:

GSM
2021 年 7 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by