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)

Homework Answers

Answer #1

Answer 4:

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

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Solve the following system of nonlinear equations: ?(?,?)=?2 +2x+2?2 -26 ?(?,?)=2?3 -?2 +4y-19 Use Newton-Raphson method....
Solve the following system of nonlinear equations: ?(?,?)=?2 +2x+2?2 -26 ?(?,?)=2?3 -?2 +4y-19 Use Newton-Raphson method. Carry out the first five iterations, startingwith? =1and? =1.
2. 2052 Write a function in MATLAB called HTBALL to calculate the height of a ball...
2. 2052 Write a function in MATLAB called HTBALL to calculate the height of a ball based on a single input, the elapsed time. The elapsed time will be a single variable in the range of 0 to 6. Predict the value by fitting a 2nd order polynominal to the data points shown below using the polyfit command. Use the command polyval to determine the height of the ball at the inputted time. timevals=[0,.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6]; height=[0,46,84,114,136,150,156,154,144,126,100,66,24]; Copy and paste the data...
Solve the following problem using the MATLAB environment Write a function [approx_root, num_its] = bisection(f,a,b,tol) that...
Solve the following problem using the MATLAB environment Write a function [approx_root, num_its] = bisection(f,a,b,tol) that implements the bisection method. You function should take as input 4 arguments with the last argument being optional, i.e, if the user does not provide the accuracy tol use a default of 1.0e-6 (use varargin to attain this). Your function should output the approximate root, approx_root and the number of iterations it took to attain the root, num_its. However, if the user calls the...
Part 2: Solve the following problems in MATLAB 1. Fill in the function E = myElim(A,...
Part 2: Solve the following problems in MATLAB 1. Fill in the function E = myElim(A, r_entry, r_pivot, c) to create an m by m elimination matrix ??. Remember that an elimination matrix looks like an identity matrix with one extra entry of ?? in row r_entry and column r_pivot. 2. Fill in the function M = myMult(A, c_pivot) to create an m by m multiplier matrix ??. Remember that a multiplier matrix looks like an identity matrix with the...
Write a C++ program to demonstrate thread synchronization. Your main function should first create a file...
Write a C++ program to demonstrate thread synchronization. Your main function should first create a file called synch.txt. Then it will create two separate threads, Thread-A and Thread-B. Both threads will open synch.txt and write to it. Thread-A will write the numbers 1 - 26 twenty times in nested for loops then exit. In other words, print 1 - 26 over and over again on separate lines for at least 20 times. Thread-B will write the letters A - Z...
Consider a consumer with the following utility function: U(X, Y ) = X1/2Y 1/2 (a) Derive...
Consider a consumer with the following utility function: U(X, Y ) = X1/2Y 1/2 (a) Derive the consumer’s marginal rate of substitution (b) Calculate the derivative of the MRS with respect to X. (c) Is the utility function homogenous in X? (d) Re-write the regular budget constraint as a function of PX , X, PY , &I. In other words, solve the equation for Y . (e) State the optimality condition that relates the marginal rate of substi- tution to...
Write a Python 3 program called “parse.py” using the template for a Python program that we...
Write a Python 3 program called “parse.py” using the template for a Python program that we covered in this module. Note: Use this mod7.txt input file. Name your output file “output.txt”. Build your program using a main function and at least one other function. Give your input and output file names as command line arguments. Your program will read the input file, and will output the following information to the output file as well as printing it to the screen:...
Please provide a brief overview on: chapter 21 1. Can I obtain the net electric field...
Please provide a brief overview on: chapter 21 1. Can I obtain the net electric field due to two or more point charges? 2. Can I obtain the net Coulomb force on a point charge due to two or more point charges? 3. Can I draw physical quantities (for example, velocity, forces or electric fields) involved in a given problem in a diagram? 4. Do I have a good "qualitative" understanding of the motion of a charged particle in a...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary rivals? How will the acquisition of Reebok by Adidas impact the structure of the athletic shoe industry? Is this likely to be favorable or unfavorable for New Balance? 2- What issues does New Balance management need to address? 3-What recommendations would you make to New Balance Management? What does New Balance need to do to continue to be successful? Should management continue to invest...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT