I have two vectors d and g with pre-allocated values (I didn't do it and there are over 1000 for both) I am supposed to do a linear fit to find a and b in the equation- g = a*d+b. Please help.
1 view (last 30 days)
Show older comments
I cannot proceed as I am new to MATLAB and cannot figure out how to find the values of a and b. dimensions : d- 1x101 double and g = 101x200 double.
Would really appreciate it if you write the code for this along with explanation, thank you.
0 Comments
Answers (1)
KSSV
on 31 Jan 2017
N = 50 ;
x = 1:N;
y1 = x + randn(1,N);
scatter(x,y1,25,'b','*')
P = polyfit(x,y1,1);
yfit = P(1)*x+P(2);
hold on;
plot(x,yfit,'r-.');
2 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!