Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. (20 points) Given the data below where t time (independent variable) [in h ho

ID: 1867877 • Letter: 1

Question

1. (20 points) Given the data below where t time (independent variable) [in h hour] and P = power (dependent variable) [in kw kilowatt], write a MATLAB script named Energy Name.m that interpolates a spline curve (cubic spline) using the MATLAB function: spline and interpolates a linear piecewise trace using the MATLAB function: interp1 (method: 'linear'). Evaluate using a time step size dt 0.1 hour. Display the plots of the data points and the interpolation methods. Use the MATLAB function: trapz to get the energy [kW-h] which is the integral or area under the curve for both spline and linear piecewise interpolation numerical methods. Report the energy values in both kWh and J. Which method estimates a higher energy value? Data t time [hl fPowerkW 37 58 81 8759 45 24 26 Expected Results for Interpolation 2 5.1 811.2 15.4 17 21.6 24 90 ?data toine 80 70 60 50 30 10 15

Explanation / Answer

clear, clc;
%% Given Data
t=[2 5.1 8 11.2 15.4 17 21.6 24];
P=[37 58 81 87 59 45 24 26];
%% Timestep dt=0.1 h
tt=0:0.1:25;
PP=spline(t,P,tt); %% Used the spline function
Power=interp1(t,P,tt)
plot(t,P,'o',tt,PP,'-',tt,Power,'b--');
%% Calculting Power by using Trapezoidal Rule
Power(isnan(Power))=[];
E_spline=trapz(PP);
E_interpo=trapz(Power);


?output

E_spline = 13259


E_interpo = 12261

?So, Spline method will get more Energy value.