Kaustav Ghosh
Kaustav Ghosh

Reputation: 25

how to create matrix functions in matlab

I want to Implement the following trigonometric system of equations in MATLAB

enter image description here What script should i write solve for x1,x2 and x4 ?

Upvotes: 0

Views: 122

Answers (1)

ThomasIsCoding
ThomasIsCoding

Reputation: 102241

You can try build a system of equations in a function f and use fsolve to solve the system, i.e.,

function y = f(x)
 y = zeros(3,1);
 y(1) =  cos(x(1)-x(2)-x(3)) - 0.707;
 y(2) =  5*cos(x(1)) + 3*cos(x(1)-x(2)) - 3;
 y(3) =  5*sin(x(1)) + 3*sin(x(1)-x(2)) - 4;
end

[x, fval, info] = fsolve (@f, [0;0;0])

such that

x =

   1.5367
   1.8755
  -1.1244

fval =

  -0.000000014158
  -0.000000103868
  -0.000000551463

info =  1

Upvotes: 1

Related Questions