Clear Filters
Clear Filters

How to always return a struct when using solve?

2 views (last 30 days)
Hello,
Using the "solve" command, as long as there is at least 2 equations to solve, MATLAB returns a struct with the fieldnames of each of the variables and the values of those fields equal to the solution for the respective variables. Is there a way to force MATLAB to return a struct instead of a sym even if there is only 1 equation (with the fieldname of the struct equal to the variable name and the value of that field equal to the solution for the 1 variable)? I'm trying to write code to work for a general application, but right now it only works if there are at least 2 equations to solve.
Thank you, Kevin

Answers (0)

Categories

Find more on Structures 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!