Create Matrix of coefficients from nonlinear function

6 Ansichten (letzte 30 Tage)
Benjamin
Benjamin am 3 Dez. 2022
Bearbeitet: John D'Errico am 11 Jan. 2023
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]
  8 Kommentare
Torsten
Torsten am 3 Dez. 2022
Bearbeitet: Torsten am 3 Dez. 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
Stephan am 3 Dez. 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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

John D'Errico
John D'Errico am 11 Jan. 2023
Bearbeitet: John D'Errico am 11 Jan. 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
eq1 = 
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)
ans = 
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.

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by