1D interpolation by y = ax+b
17 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have x and y data. I need interpolate (fit) data by y = a*x + b
0 comentarios
Respuestas (1)
Star Strider
el 27 de Feb. de 2021
To set the start point at the origin (0,0), calculate the slope as:
slope = x(:) \ y(:);
for example:
x = 0:0.1:10;
y = rand(size(x));
slope = x(:) \ y(:);
figure
plot(x, y, '.b')
hold on
plot(x, slope*x, '--r')
hold off
grid
xlabel('x')
ylabel('y')
.
6 comentarios
Star Strider
el 27 de Feb. de 2021
I do not have the Curve Fitting Toolbox (since I do not need it for what I do in my research). This requirement was not implied or stated in the original Question you posted.
Without your data, I cannot code a similar function using the Statistics and Machine Learning Toolbox or the Optimization Toolbox functions, both of which I have and frequently use. I would need more information to provide an appropriate response.
Ver también
Categorías
Más información sobre Interpolation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!