Csn you please solve using MATLAB II rite a function program

Csn you please solve using MATLAB

II. rite a function program called function (a,b) bestline(xy,n) whose inputs are the vectors x and y of size n. The outputs a,b are the slope and the intercept respectively of the \"best\" straight line fit through the n data points whose coordinates are given the vectors x and y The values of \"a\" and \"b\" are given as Note: The symbol 2 represents the summation over the n points III. Write a script file called Problem3 where the user reads in values of time and temperature and the program plots the best straight line fit between the given temperature and time. Use data from Problem I to get your input values for time and temperature. (Note: You are free to use the function program that you wrote for Problem II to get the values of a and b for this problem) You need present both your script file and the output plot in your solution Bonus Problem you do not have to turn this in) See if you can also plot Time vs Wind Velocity on the same plot as Problem III

Solution

function [a b]= bestline(x,y,n)
XY=x.*y;
X2=x.*x;
a=(n*(sum(XY))-sum(x)*sum(y))/(n*(sum(X2))-(sum(x)^2));
b=sum(y/n)-a*sum(x/n);

Csn you please solve using MATLAB II. rite a function program called function (a,b) bestline(xy,n) whose inputs are the vectors x and y of size n. The outputs a

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site