Create Matrix of coefficients from nonlinear function
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
This is the code im using. Based on question 3, I believe it is x^1, x^2, x^3, x^4 NOT x1 x2 x3 x4.
I attempted to use "[A]=equationsToMatrix(eqns)" but it states that it can not compute non linear equations.
syms x [4 1]
eqn1=16*x^1+32*x^2+33*x^3+13*x^4==91;
eqn2=5*x^1+11*x^2+10*x^3+x^4==16;
eqn3=9*x^1+7*x^2+6*x^3+12*x^4==5;
eqn4=34*x^1+14*x^2+15*x^3+x^4==43;
eqns=[eqn1;eqn2;eqn3;eqn4]
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1217997/image.png)
8 comentarios
Torsten
el 3 de Dic. de 2022
Editada: Torsten
el 3 de Dic. de 2022
The x in your assignment question is the vector x consisting of the four components x(1), x(2), x(3) and x(4).
I already wrote so, but you don't seem to read carefully.
And if you use the command
solve(eqns)
you can skip the line
[A,b]=equationsToMatrix(eqns)
because A and b are not used.
Stephan
el 3 de Dic. de 2022
The question also is asking for the vector b which is 4x1 too. Why do you accept b as a vector but not x? Note that linear systems have the form A*x=b with A being a n*n matrix and b & x being vectors of size n*1.
Respuestas (1)
John D'Errico
el 11 de En. de 2023
Editada: John D'Errico
el 11 de En. de 2023
I'm sorry, but you are most certainly incorrect.
A system of 4 equations like that would have 4 unknowns. In what you were shown, there are 4 unknowns listed. They are called x1,x2,x3,x4.
But it makes absolutely NO sense to have a system of 4 equations with ONE unknown, where the unknown is the same variable in all four equations. That is, suppose you wrote this as
syms x
eq1 = 16*x^1 + 32*x^2 + 33*x^3 + 13*x^4 == 91
As one polynomial equation, in one unknown, it has 4 roots. We can compute those roots easily enough, using solve. or vpasolve, for example.
vpasolve(eq1)
However, it makes no sense to pose a system of 4 polynomial equations like that, all with the SAME variable x. Each equation will have totally different roots, but no root in common. And there would not be any reason to call it a "system of equations" if your thinking about the equations was correct.
So I am sorry, but you are completely incorrect. There are 4 unknowns. Call them x1,x2,x3,x4. Call them x,y,z,w. Call them fred, barney, wilma, pebbles as you wish. But they ARE NOT powers. Yes, I know, you think it was a typo, and that you expected to see powers there. They are just 4 distinct variables.
And when you do write the problem in terms of 4 unknowns as I have suggested, now equationsToMatrix will work perfecly well.
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!