Question

# Question 4 MATLAB a) Write a function file called q4.m containing the following nonlinear equations. ?(?1?2...

Question 4 MATLAB

a) Write a function file called q4.m containing the following nonlinear equations. ?(?1?2 ) = ?1 2 + ?2 2 − 26

?(?1?2 ) = 3?1 2 + 25?2 2 − 100 (1 Mark)

b) Use MATLAB’s FSOLVE operator to solve these equations with x1 = 2 and x2 = 2 as your starting point. How many iterations did MATLAB use to solve them? (1 Mark)

Part (a)

```%% Part (a) q4.m file

function f = q4(x)
f(1) = x(1)^2 + x(2)^2 - 26;
f(2) = 3*x(1)^2 + 25*x(2)^2 - 100;
end```

Part (b)

```%% Part (b)

% Get the function from q4.m
F = @q4;
% Given starting points
x1 = 2;
x2 = 2;
% Solve the function
[x, fval, exitflag, output] = fsolve(F, [x1, x2]);
% Print the solution
fprintf("The solution for F is\n");
fprintf("\tx1 = %f\n", x(1));
fprintf("\tx2 = %f\n", x(2));
fprintf("The number of iterations is %d\n", output.iterations);```

Output:

Kindly rate the answer and for any help just drop a comment