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 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
KSSV
2017 年 1 月 31 日
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 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!