Here is the Matlab code for the above problem:(make sure you have curve fitting tool box installed in matlab)
%% dataFitting.m
% put data in excel sheet in sheet1 in below format:
% xtitle ytitle
% x1 y1
% x2 y2
% x3 y3
% x4 y4
clc;
[FileName,PathName] = uigetfile({'*.xlsx';'*.xls'},'Select the
excel file');
[num,text,raw] = xlsread(FileName,1);
x=num(:,1);
y=num(:,2);
answer=inputdlg('Enter the degree of
polynomial(degree<=9)');
answr=str2double(answer{1});
if ~isnumeric(answr)
error('Enter a number less than or equal to
9');
return;
end
if (answr)>9
disp('degree can''t be greater than
9...');
disp('proceding with degree 9 ');
deg=9;
else
deg=answr;
end
%% curve fitting
disp('Analytical function that represents data is:');
curve=fit(x,y,['poly' num2str(deg)])
%% plotting data
plot(curve,x,y)
title('Actual Data Vs Fitted Data');
xlabel(text(1));
ylabel(text(2));
p=coeffvalues(curve);
%% calculating rms error
yfit=polyval(p,x);
numerator = sum((yfit-y).^2);
denominator= length(x);
if length(x)==1
denominator=1;
end
RMSError = numerator / denominator;
fprintf('RMS error between actual data and fitted data
is:%f\n',RMSError);
disp('**end**');
Project 2: (Data fitting-interpolating) Write a code that uses Matlab to read the data form an...
MATH 220 Project 1 Polynomial Curve Fitting It desired to fit a polynomial curve through evenly spaced (x-direction) points. The general form of a polynomial is: f(x) = 4,x" +47-1X2-1 + + ax + ao If one wishes to fit a curve through, say 4 points, one would need a 3rd degree polynomial (n = 3) such that 4 unknown constants could be evaluated. In the absence of availability of many wathematical programming tools (Matlab, etc., Mathematica is available as...
2. Consider interpolating the data (x0,yo), . . . , (x64%) given by Xi | 0.1 | 0.15 | 0.2 | 0.3 | 0.35 | 0.5 | 0.75 yi 4.0 1.0 1.22.12.02.52.5 For all tasks below, please submit your MATLAB code and your plots. You can write all code in a single (a) Using MATLAB, plot the interpolating (6th degree) polynomial given these data on the domain .m-file [0.1,0.75] using the polyfit and polyval commands. To learn how to use...
**********************matlab code please******************* 1. Interpolation error of polynomial fit Using 11 equi-distributed points (10 equal segments) in the interval [-1 1], Using Newton's form find and plot the interpolating polynomial p(x) for the function f(x) -1/(125x2). Comment on the large discrepancies between p(x) and the function f(x) that the data came from Write down an expression for the error in the interpolating polynomial above? Which part of the expression is responsible for the large errors observed? 1. Interpolation error of...
matlab code Task 2 (30 points +4 for comments): Write computer code that uses Lagrange's nterpolating Polynomials to fit an interpolating polynomial to the data for Task 2 in the excel file and use the polynomials to interpolate the data set and evaluate the function value at x values of 8.4, 7.6, and 6.7 What are the first through 3rd order estimations for the interpolated function value at> 8.4 and x 7.6? a) b) Extrapolate the data set to determine...
Please use matlab, post the code, and dont just write the code by hand. Thank you! 4 [3 points] Use the function f(x on the interval [5, 5] and the 11 points below to find a N-10 Lagrange polynomial, using MATLAB. You will need to write code for and plot the polynomial as a function of x, but you do not have to write the polynomials down by hand 5 0 2 3 4 5 f(x) | 0.0399 | 00623...
Please use a MATLAB code to execute the above. 2. Use polyfit to find a 4rd degree polynomial to fit the following set of data: Value =-4:1:5; Vibration = [-507.6,-261.88,-100.03,-38.08, 69, 753, 15.6, 51.8, 182, 428.97]. Plot the best fitting curve and the data points on the same figure.
Matlab: a) Write a program to compute the first-degree and third-degree polynomials that fit the data, displaying the polynomial coefficients. Remember to include text to describe the displayed coefficients. (b) Compute and display (including what the information is) the sum of the squares for each curve fit. (c) Plot the data and the two curve fits on a single plot, for 101 values of A in the range 0 ? A ? 9. Choose different line styles for each curve...
Fit a polynomial to data and plot it density_water.dat density_air.dat Step 1: write code to read the density-vs-temperature of both water and air data into two lists/arrays. (hint: for each row, you need to detect if first character is #, if so skip it, otherwise parse the data and save it to lists below). Water_temp=[] water_density=[] Air_temp=[] air_density=[] Step 2 Read the description below to generate a polynomial function that fit the data. Step 3: plot the results of the...
How do your write this in Matlab. Create a program that takes as input: An integer nFunction that is either 1 or 2 indicating which of the two functions below to nsc * An integer n in [1.oc) indicating how many data points (ro."). ·The left endpoint a of an overall interval. (n泓) tote. The right endpoint b of an overall interval Your program should find the interpolating polynomial of degree less than or equal to of the requested function...
Linear Algebra. please complete or show me how to to complete it. idk what to do. thank you Curve Fitting It is desired to fit a polynomial curve through evenly spaced (x-direction) points. The general form of a polynomial is: f(x) = 4x + 4-1x* +ajx + ao If one wishes to fit a curve through, say 4 points, one would need a 3rd degree polynomial (n = 3) such that 4 unknown constants could be evaluated. In the absence...