Use a structure with fields in a loop - Outputs & indexing ??

1 view (last 30 days)
Dimitris K
Dimitris K on 10 Sep 2021
Commented: Dimitris K on 10 Sep 2021
Hello everyone,
I am using a structure to output all my results from a function organised in different fields. My struct contains 10 fields - and as my loop has 101 steps my struct ends up being a struct array (1*101) with 10 fields.
Some of my fields are numeric arrays e.g. Sig (6*1) and i want to use the first value of each of these Sig in the 101 fields to plot them. How could i do this easily?
The way i thought is:
Is there a better suggestion?

Accepted Answer

Stephen on 10 Sep 2021
Where S is your structure:
F = @(a)a.Sig(1);
V = arrayfun(F,S)
Dimitris K
Dimitris K on 10 Sep 2021
Thanks a lot for your answers !! It was very helpful!!!!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!