Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

How can I do loop for struct data?

1 visualizzazione (ultimi 30 giorni)
Riyadh Muttaleb
Riyadh Muttaleb il 18 Apr 2016
Chiuso: MATLAB Answer Bot il 20 Ago 2021
I have a data set that consist of a structure , example: data (1x10 struct with 1 field) How can I do loop to read all these data? I want to be able to do a calculation on a specific measurements of each field. Thanks

Risposte (2)

Azzi Abdelmalek
Azzi Abdelmalek il 18 Apr 2016
a=struct('f',num2cell(1:10))
out=[a.f]
  6 Commenti
Azzi Abdelmalek
Azzi Abdelmalek il 20 Apr 2016
suppose you have this matrix
A=[1 2;3 4;5 6]
What operation you want to apply?
Riyadh Muttaleb
Riyadh Muttaleb il 21 Apr 2016
b=2/3*A(i,j)

Walter Roberson
Walter Roberson il 19 Apr 2016
Example:
arrayfun(@(IDX) mean(YourStructArray(IDX).TheField(:)), 1:numel(YourStructArray))

Questa domanda è chiusa.

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by