Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please help me modify the Matlab codes, please do not change some variable names, thanks hw00Bpractice.mat can be download from there https://drive.google.com/open?id=1qCAaTPF0sIkyfzx__fJAhvkklcPJuPLh some of codes
please help me modify the Matlab codes, please do not change some variable names, thanks
hw00Bpractice.mat can be download from there https://drive.google.com/open?id=1qCAaTPF0sIkyfzx__fJAhvkklcPJuPLh
some of codes provided:
% clear the workspace of old values clear % load the practice data & list variables load hw00Bpractice.mat whos A = [t ones(size(t))]; % redo these lines %M = A; %v=b; % linear solve c = Mv; z = c(1)*t+c(2); %keep and do not change the below codes disp('grading variables list: z, Err') % pre-written Plotting section figure(1) clf hold on plot(t,y,'bo') plot(t,z,'r') grid on xlabel('t','fontsize',15) ylabel('y','fontsize',15) title('Least Squares Fit to Random Data','fontsize',15) legend({'Data', 'Fit'},'fontsize',15)
Linear Algebra The following problem will review basic linear algebra operations in Matlab. The code you have been provided performs a linear least squares fit on some noisy data. We will modify it so that it instead performs a quadratic least-squares fit on the same data. You do not need to know the best-fit theory, the worksheet below is designed to be a warm-up to matrix-vector arithmetic in Matlab. Start by running the code hw00Bpractice.m as is. There is information in the screen output and the plot. The code starts by loading the practice data from the file hw00Bpractice.mat; and the whos command gives a list of the data variables. List below all variables and identify them as scalar, vector or matrix quantities (with sizes): Now you are ready to perform the quadratic fit, but note that you will have to be aware of Matlab's element-wise arithmetic. Modify A to be N x 3, with the first column equalling t2, the second column equalling t, and the third column equalling all 1's. Give the new values of M and v. Finally, modify the Matlab vector z so that zj = qt, + c2tj + C3, where cj are the entries ofc-give the best-fit quadratic polynomial Finally, check that your plotted quadratic looks like the best-fit polynomial, and calculate the aver- age squared-error again
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started