Trying to find values within a struct with a case
Show older comments
Hello,
I am working to extract the values of a 1x9 Struct (named FMtest) with 5 fields (named alpha, gamma, Fy, Fz, Mz). I need to find each measurement where alpha is 0 and then fit it to find further values (Cfa and Fy0 in my code
idx = find([FMtest(1:9).alpha] == 0);
pfy = polyfit(FMtest(1:9).alpha(idx),FMtest(1:9).Fy(idx),1);
Cfa = pfy(1)
Fy0 = pfy(2)
idx is returned as [53,156,259,361,463,565,667,769,871] which I am assuming corresponds to the array indicies where alpha is 0.
However, I am running into the following errors when trying to fit this case back on the struct
Errors:
Expected one output from a curly brace or dot indexing expression, but there were 9 results.
Error in RVD_Assignment4 (line 26)
pfy = polyfit(FMtest(1:9).alpha(idx),FMtest(1:9).Fy(idx),1);
Thank you,
Alex
Accepted Answer
More Answers (0)
Categories
Find more on Data Type Identification in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!