Question: In this section, you will be writing a function m-file, called pnfit_, that you will be able to use to generate plots for your lab
In this section, you will be writing a function m-file, called pnfit_, that you will be able to use to generate plots for your lab reports. This will be useful whenever the experimental data is modeled by a polynomial, say of the form: y = anx n + an-1 x n-1 + ... + a1x + a0; Your pnfit function will have inputs: n, the degree of the polynomial that we expect to fit the data; x, a vector of the x-components of the observed data; and y, a vector of the y-components of the observed data. and outputs a vector 'coef ' containing the least-squares estimate of the polynomial coefficients; and e 2 , the sum of the squared errors = 2 2 e (y y ) . ECE 309 Project #3 Page 2 of 7 Spring 2025 Part 1.2 - Testing your pnfit function Write a script m-file, called test_ pnfit_xxxx, to test pnfit_xxxx. This m-file should: 1. Prompt the user to supply 'n', the x-axis label, the y-axis label, and the plot title. 2. Generate the 'x' and 'y' vectors using polyval() as indicated below. 3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
