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 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
KSSV
el 31 de En. de 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 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!