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

using this excel sheet, i have to do this homework for MATLAB and need help 1. W

ID: 3683361 • Letter: U

Question

using this excel sheet,

i have to do this homework for MATLAB and need help

1. Write a program that imports the data from the first excel sheet and plot each data set on the same plot. Create another program that plots all the data on its own graph but in the same window. Remember to include titles, legends, and axes labels.
2. Write a program that will read the data from the second tab. Use polyfit to create a linear best fit line. Calculate the R2 value for fit. Plot both the individual data points (red) and the fit line (blue) on the same graph. Include a title and axis labels.

Mass = 1 kg Mass = 5 kg Mass = 10 kg Mass = 15 kg Mass 20 kg Height (m) Energy (J) Height (m) Energy (J) Height (m) Energy (J) Height (m) Energy (J) Height (m) Energy (J) 0 0 0 0 0 0 0 0 0 0 5 49.05 5 245.25 5 490.5 5 735.75 5 981 10 98.1 10 490.5 10 981 10 1471.5 10 1962 15 147.15 15 735.75 15 1471.5 15 2207.25 15 2943 20 196.2 20 981 20 1962 20 2943 20 3924 25 245.25 25 1226.25 25 2452.5 25 3678.75 25 4905 30 294.3 30 1471.5 30 2943 30 4414.5 30 5886 35 343.35 35 1716.75 35 3433.5 35 5150.25 35 6867 40 392.4 40 1962 40 3924 40 5886 40 7848 45 441.45 45 2207.25 45 4414.5 45 6621.75 45 8829 50 490.5 50 2452.5 50 4905 50 7357.5 50 9810 55 539.55 55 2697.75 55 5395.5 55 8093.25 55 10791 60 588.6 60 2943 60 5886 60 8829 60 11772 65 637.65 65 3188.25 65 6376.5 65 9564.75 65 12753 70 686.7 70 3433.5 70 6867 70 10300.5 70 13734 75 735.75 75 3678.75 75 7357.5 75 11036.25 75 14715 80 784.8 80 3924 80 7848 80 11772 80 15696 85 833.85 85 4169.25 85 8338.5 85 12507.75 85 16677 90 882.9 90 4414.5 90 8829 90 13243.5 90 17658 95 931.95 95 4659.75 95 9319.5 95 13979.25 95 18639 100 981 100 4905 100 9810 100 14715 100 19620 105 1030.05 105 5150.25 105 10300.5 105 15450.75 105 20601 110 1079.1 110 5395.5 110 10791 110 16186.5 110 21582 115 1128.15 115 5640.75 115 11281.5 115 16922.25 115 22563 120 1177.2 120 5886 120 11772 120 17658 120 23544 125 1226.25 125 6131.25 125 12262.5 125 18393.75 125 24525 130 1275.3 130 6376.5 130 12753 130 19129.5 130 25506 135 1324.35 135 6621.75 135 13243.5 135 19865.25 135 26487 140 1373.4 140 6867 140 13734 140 20601 140 27468 145 1422.45 145 7112.25 145 14224.5 145 21336.75 145 28449 150 1471.5 150 7357.5 150 14715 150 22072.5 150 29430 155 1520.55 155 7602.75 155 15205.5 155 22808.25 155 30411

i have to do this homework for MATLAB and need help

1. Write a program that imports the data from the first excel sheet and plot each data set on the same plot. Create another program that plots all the data on its own graph but in the same window. Remember to include titles, legends, and axes labels.
2. Write a program that will read the data from the second tab. Use polyfit to create a linear best fit line. Calculate the R2 value for fit. Plot both the individual data points (red) and the fit line (blue) on the same graph. Include a title and axis labels.

Explanation / Answer

Use MATLAB programs as shown below to achive your task:


(1.)
[v,T,vT]=xlsread('name.xls')
% 'xlsx' for exell 2007
%v: Double
%T and vT : cell
%use v containing numbers
t=v(:,1);y=v(:,2)
%if u have to plot second colone depending on first:
plot(t,y)

x1= [1 2];
y1 = [4 4];
ntimes = 100;
denom = 1;
k = -1;
subplot(1,2,1)
hp1 = plot(x1,y1);
xlabel('Updated with REFRESHDATA')
ylabel('pi')
set(gca,'Xlim',[0 ntimes],...
'Ylim',[2.5 4])
set(hp1,'XDataSource', 'x1')
set(hp1,'YDataSource', 'y1')
for t = 3:ntimes
denom = denom + 2;
x1(t) = t;
y1(t) = 4*(y1(t-1)/4 + k/denom);
refreshdata
drawnow
k = -k;
end
line([0 ntimes], [pi pi],'color','c')


(2)
x = 1:10;
y1 = x + randn(1,10);
scatter(x,y1,25,'b','*')
P = polyfit(x,y1,1);
yfit = P(1)*x+P(2);
hold on;
plot(x,yfit,'r-.');