Coder error - Directly accessing field or property of nonscalar struct or object not supported for code generation
18 views (last 30 days)
Show older comments
Richard Burger
on 21 Oct 2020
Commented: Richard Burger
on 21 Oct 2020
The following line of MATLAB code causes the coder error “Directly accessing field or property of nonscalar struct or object not supported for code
Generation”
healthy = ~Health(SignalIndex).HasData(SatIndex,EphemIndex);
I have seen the following Mathworks page:
The work around cited doesn’t address my particular problem (or I can’t see that it does). Can you suggest a work around please?
0 Comments
Accepted Answer
Walter Roberson
on 21 Oct 2020
The code is not valid MATLAB unless SignalIndex is either a scalar number or else a logical array that is certain to have exactly one true in it.
Break the code into two parts. In the first part, do the structure indexing and assign the selected scalar structure to a variable. In the second part access the appropriate field of the scalar structure.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!