Question

Please solve using matlab and post the code used1) Consider the following input data: x = [O 3.6 10 12 16.4 18.4 24]; y = [52 32.830 6.670 7 5.030 2*pi 8]; Use polyfit to a)

0 0
Add a comment Improve this question Transcribed image text
Answer #1


$$Matlab code for polyfit and polyval clear all close all $input data x=[0 3.6 10 12 16.4 18.4 24]; y=[52 32.83 6.67 7 5.03 2computational time vs. order number plot computational time (1) di 15 2 2.5 3 order (n) 3.5 4 4.5 Published with MATLAB® R201

%%Matlab code for polyfit and polyval
clear all
close all

%input data
x=[0 3.6 10 12 16.4 18.4 24];
y=[52 32.83 6.67 7 5.03 2*pi 8];

%desired order
n=[1 2 3 4 5];
for i=1:5
  
    tic
    p=polyfit(x,y,n(i));
    p_val=polyval(p,x);
    tt(i)=toc;
    err=norm(p_val-y);
    fprintf('For n=%d error norm=%f\n',i,err)
    fprintf('\tComputational time = %f\n',tt(i))
  
end
  
plot(n,tt)
xlabel('order (n)')
ylabel('computational time (t)')
title('computational time vs. order number plot')

%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%

Add a comment
Know the answer?
Add Answer to:
Please solve using matlab and post the code used 1) Consider the following input data: x...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Homework 5 (35 Points max) Please Submit all Matlab and Data files that you create for this homew...

    Homework 5 (35 Points max) Please Submit all Matlab and Data files that you create for this homework Problem 1 (max 20 Points): For the second-order drag model (see Eq.(1)), compute the velocity of a free-falling parachutist using Euler's method for the case where m80 kg and cd 0.25 kg/m. Perform the calculation from t 0 to 20 s with a step size of 1ms. Use an initial condition that the parachutist has an upward velocity of 20 m/s at...

  • Please solve this using matlab and type in the codes here The following data was obtained...

    Please solve this using matlab and type in the codes here The following data was obtained when the stopping distance d of a car on a wet road was measured as a function of the speed v when the brakes were applied: v (mi/h) 12.5 25 37.5 50 62.5 75 d (ft) 20 59 118 197 299 420 Use polyfit function to determine the coefficients of a quadratic polynomial d = a_2 v^2 + a_1 v + a_0 that best...

  • Using Matlab. The following calibration data are from a hot wire anemometer (HWA) velocity measurement system for air...

    Using Matlab. The following calibration data are from a hot wire anemometer (HWA) velocity measurement system for air flow: Air Velocity, V (m/s) HWA Output Voltage (E) 0.0 1.100 1. 1.1 1.362 2. 1.431 1.5 3. 1.487 2.0 4. 1.535 2.5 5. 1.576 6 3.0 1.647 4.0 7. 1.706 8. 5.0 1.780 9. 6.5 1.841 10. 8.0 1.910 10 11. 1.983 12. 13 13. 16 2.072 14. 20 2.159 15. 25 2.257 16. 32 2.379 17. 40 2.500 1. Perform...

  • use matlab 6. You have a x-y relationship as follows 1 2 3 4 5 6 7 8 10 X 17.52 22.76 24.22 36.83 37.65 51.32 68.3...

    use matlab 6. You have a x-y relationship as follows 1 2 3 4 5 6 7 8 10 X 17.52 22.76 24.22 36.83 37.65 51.32 68.35 74.59 4.382 1.787 7.757 3nd order polynomial to curve-fit this relationship, i.e. We want to use a yaaxax +a^x (8) (a) Determine the coefficients of the polynomial by solving the following equation a (9) y's az a, (b) Determine the coefficients of the polynomial by using function polyfit (c) Make a plot showing...

  • Need help with this question on matlab. Show code please! Salmon_dat.csv 272395 286156 391573 461443 401998...

    Need help with this question on matlab. Show code please! Salmon_dat.csv 272395 286156 391573 461443 401998 313120 240763 297488 446152 480276 420555 277697 357375 331788 420879 332479 320947 359853 300917 403286 416419 345028 256049 281980 286625 278560 344422 317956 219688 259337 208197 189419 272884 360673 248860 306981 401711 867728 870035 921314 846026 570413 493708 275954 518942 480284 809799 677171 589937 1129664 1152642 Exercise 1: Salmon Runs Download the file salmon-dat.csv included with the homework. This file con- tains the annual...

  • **********************matlab code please******************* 1. Interpolation error of polynomial fit Using 11 equi-dist...

    **********************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...

  • Use matlab a) Create a simulated data set b) Create a set of plots to determine...

    Use matlab a) Create a simulated data set b) Create a set of plots to determine the best transformation to linearize the data c) Fit a first order polynomial (y mx + b) to the linearized data to find the constants m and b d) Reconstruct the original equation from m and b in the linear fitted polynomial e) Plot the fitted equation. Radioactive decay is modeled by the equation: rt where A the amount of mass as a function...

  • 1. [12 marks] In the following parts of this question, write a MATLAB code to solve a linear syst...

    1. [12 marks] In the following parts of this question, write a MATLAB code to solve a linear system A b (A is a square nonsingular matrix) using Jacobi and Gauss-Seidel algorithms. Do not use the built-in Matlab functions for solving linear systems (a) Write a Matlab function called Jacobi that consumes a square n x n matrix A, and an n x 1 vector b, and uses the Jacobi technique to solve the system Ax-b, starting with the zero...

  • Q: please solve using matlab code withe comment 1.      Write the Matlab code to generate: x...

    Q: please solve using matlab code withe comment 1.      Write the Matlab code to generate: x = cos(w1*t) + cos(w2*t); where, w1=7; w2=23; t = [0:0.005:2] 2.   Plot the signal using sub plot a.   in time domain b.   in frequency domain 3)   Sample the signal under different sampling conditions: a.      Ts<1/2fm b.      Ts=1/2fm c.       Ts>1/2fm 4).      Multiple plot: the signal sampled under sampling condition and the signal x a.      in time domain b.      in frequency domain c.       Label and Title...

  • Show work by hand and also using MATLAB code. Model 1 Given a polynomial f(x) Write a first-order approximation of f(x), given the value of f(x) at two points Plot the polynomial and the first-or...

    Show work by hand and also using MATLAB code. Model 1 Given a polynomial f(x) Write a first-order approximation of f(x), given the value of f(x) at two points Plot the polynomial and the first-order approximation on a graph Write a second-order approximation of f(x), given the value at three points. Plot the polynomial, the first-order and second-order approximations on a graph Find the integral Exactly Using trapezoidal rule Using composite trapezoidal rule Using Simpson's 1/3 rule . Calculate the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT