Coefficients in simple equations, y not represented all the time

5 次查看(过去 30 天)
I have the equations x=0, and z=50000. Written as a=x==0, and b=z==50000. Potentially in other examples maybe all variables (x,y,z) are represented in the equations, I would like matlab to tell me the coefficients of x,y and z in both equations. For example the x=0 equation would tell me I have 1 x, 0y, 0z as the coefficents. Another exmaple is the other equation would tell me I have 0x,0y and 1 z.
  2 个评论
katherine keogh
katherine keogh 2021-1-12
Okay I have it so that I use children to seperate the equations from the numbers at the end
and then I can get the coefficients but I want it so that it will tell me if there are no xs or zs or ys rather than just omitting the 0s
dpb
dpb 2021-1-12
编辑:dpb 2021-1-13
More info on what you're doing and how to use this probably would lead to some other feedback, but if you have the Statistics or CurveFitting TB there are options to use a fitobject or linearmodel object that contains information on coefficients, variables, etc., ...
Other than that, a mechanism such as holding the coefficients vector where the terms are related positionally is about the best one can do in ordinary procedural code; one could write a special class of one's own to deal with somewhat similarly as do the two objects above without all the bells and whistles.
Or, there is the Symbolic TB to treat that way...I've never used/had it so not all that familiar.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Particle & Nuclear Physics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by