Use Matlab and write entier script Problem 1. Using the information above, find y(n) for all n...

90.2K

Verified Solution

Question

Mechanical Engineering

Use Matlab and write entier script

Problem 1.

Using the information above, find y(n) for all n between1:N.

y(tn)=mx(tn)+b+r(tn)

y=mx+b

Plot the points on a graph, without connecting them with aline.   Use a command like:

plot( x, y, ‘.r’ )

Now we want to find the “best fit” solution.   As wasmentioned before, this was defined in the prior exercise. (You maywish to read this to understand how the algorithmworks.)   Use the MATLAB code below.

You have the vectors x and y already. You need a vector I, whichis a column which each element equal to 1.

Programming Steps:

I = ones(length(x),1);

u = [ x , I ];

w = (u’ * u) \ ( u’ * y) ;

The result is an estimate of the values of m and b.  The estimate for m is w(1) and the estimate for b is w(2). Theresulting estimate for y is:

               y_est = u * w;

Answer & Explanation Solved by verified expert
3.5 Ratings (254 Votes)
MATLABCODEclcclearn10 number of elements in xm5 assumed mb1 assumed    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students