Csn you please solve using MATLAB II. rite a function program called function (a
ID: 2317569 • Letter: C
Question
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 IIIExplanation / Answer
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);
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.