Entering Non-Linear System of Equations
Hi All. I am fairly new to Matlab and still learning. I am wondering if one may explain to me how I should enter a system of non-linear equations. For instance the equations I have are: 4*x(1)-x(2)+x(3)-x(1)*x(4) = 0; -x(1)+3*x(2)-2*x(3)-x(2)*x(4) = 0; and x(1)^2+x(2)^2+x(3)^2-1 = 0. Basically I want to enter the equations and use the Newton Method to solve using the Jacobian Matrix. This is how I enetered them in Matlab:
clear all
clc
syms x
f1 = 4*x(1)-x(2)+x(3)-x(1)*x(4);
f2 = -x(1)+3*x(2)-2*x(3)-x(2)*x(4);
f3 = x(1)^2+x(2)^2+x(3)^2-1;
F = [f1;f2;f3];
If I tell the program to run at this point, this is the error I happen to get:
??? Error using ==> mupadmex
Error in MuPAD command: Index exceeds matrix dimensions.
Error in ==> sym.sym>sym.subsref at 1366
B = mupadmex(‘mllib::subsref’,A.s,inds{:});
Error in ==> NewtonMethosNonLinear at 5
f1 = 4*x(1)-x(2)+x(3)-x(1)*x(4);
I would appreciate some explanation on this since I don’t know how to move next. Thank you.Hi All. I am fairly new to Matlab and still learning. I am wondering if one may explain to me how I should enter a system of non-linear equations. For instance the equations I have are: 4*x(1)-x(2)+x(3)-x(1)*x(4) = 0; -x(1)+3*x(2)-2*x(3)-x(2)*x(4) = 0; and x(1)^2+x(2)^2+x(3)^2-1 = 0. Basically I want to enter the equations and use the Newton Method to solve using the Jacobian Matrix. This is how I enetered them in Matlab:
clear all
clc
syms x
f1 = 4*x(1)-x(2)+x(3)-x(1)*x(4);
f2 = -x(1)+3*x(2)-2*x(3)-x(2)*x(4);
f3 = x(1)^2+x(2)^2+x(3)^2-1;
F = [f1;f2;f3];
If I tell the program to run at this point, this is the error I happen to get:
??? Error using ==> mupadmex
Error in MuPAD command: Index exceeds matrix dimensions.
Error in ==> sym.sym>sym.subsref at 1366
B = mupadmex(‘mllib::subsref’,A.s,inds{:});
Error in ==> NewtonMethosNonLinear at 5
f1 = 4*x(1)-x(2)+x(3)-x(1)*x(4);
I would appreciate some explanation on this since I don’t know how to move next. Thank you. Hi All. I am fairly new to Matlab and still learning. I am wondering if one may explain to me how I should enter a system of non-linear equations. For instance the equations I have are: 4*x(1)-x(2)+x(3)-x(1)*x(4) = 0; -x(1)+3*x(2)-2*x(3)-x(2)*x(4) = 0; and x(1)^2+x(2)^2+x(3)^2-1 = 0. Basically I want to enter the equations and use the Newton Method to solve using the Jacobian Matrix. This is how I enetered them in Matlab:
clear all
clc
syms x
f1 = 4*x(1)-x(2)+x(3)-x(1)*x(4);
f2 = -x(1)+3*x(2)-2*x(3)-x(2)*x(4);
f3 = x(1)^2+x(2)^2+x(3)^2-1;
F = [f1;f2;f3];
If I tell the program to run at this point, this is the error I happen to get:
??? Error using ==> mupadmex
Error in MuPAD command: Index exceeds matrix dimensions.
Error in ==> sym.sym>sym.subsref at 1366
B = mupadmex(‘mllib::subsref’,A.s,inds{:});
Error in ==> NewtonMethosNonLinear at 5
f1 = 4*x(1)-x(2)+x(3)-x(1)*x(4);
I would appreciate some explanation on this since I don’t know how to move next. Thank you. jacob shila MATLAB Answers — New Questions