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

I really need help on thie MATLAB homework BE 1500 – Homework 6 1. Write a progr

ID: 3683156 • Letter: I

Question

I really need help on thie MATLAB homework

BE 1500 – Homework 6
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

1) Create your own xl file.

2) create main,m file

3) create Rsquare,m file

Q1) & Q2 same programs are to be used

main program file _________main,m___

data = xlsread(filename, 2) ; %
x= data( 1: 20, 1) ;
y= data(1: 20, 2) ;
p = polyfit(x,y,1)
f= polyval(p,x);
r2=Rsquare(x,y,p);
h2=figure;subplot(211);
plot(x,y,'r') ; hold on;
subplot(212);
plot(x,f,'-b'); % show linear fit

Second file _________Rsquare,m___

function [r2]=Rsquare(x,y,p)

Ymeasure=y;
Ycalculate=(p(1)*x)+p(2);
meanY=mean(Ymeasure);
deltaY2=sum((Ycalculate-Ymeasure).^2);
distanceY2=sum((Ymeasure-meanY).^2);
r2=1-(deltaY2/distanceY2);
%----