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

I need to use MATLAB to interpolate this weather data. Weather Column 1(month) C

ID: 2315320 • Letter: I

Question

I need to use MATLAB to interpolate this weather data.

Weather

Column 1(month) Column 2( temp 0C)

This is the MATLAB script I wrote but it is not working

clc;
clear;
format compact;

M = [ 1 3 6 9 12 15 18 21 24 27 30 33 36 39 42 42 48];
T = [ 5 10 20 13 7 12 22 10 10 15 26 20 6 13 25 18 10];

x = 1:1:48;
y =interp1(M,T,x,'spline');
plot(M,T,'o',x,y),title('Temperature vs. Month'),...
xlable('Month'),ylable('Temperature, degrees C'),
set(gca,'XMinorTick','on', 'YMinorTick','on')

Can someone please help

1 5 3 10 6 20 9 13 12 7 15 12 18 22 21 10 24 10 27 15 30 26 33 20 36 6 39 13 42 25 45 18 48 10

Explanation / Answer

The below code works,the error is in M vector 42 is repeated but in table it is 42 45 48 ,I have changed that you can observe it,now the code is working

M = [ 1 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48];

T = [ 5 10 20 13 7 12 22 10 10 15 26 20 6 13 25 18 10];

x = 1:1:48;
y =interp1(M,T,x,'spline');
plot(M,T,'o',x,y),title('Temperature vs. Month'),...
xlable('Month'),ylable('Temperature, degrees C'),
set(gca,'XMinorTick','on', 'YMinorTick','on')