Trying to find values within a struct with a case
이전 댓글 표시
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
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Data Type Identification에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!