
How can I draw the fitted curve and find the initial slope of the attached plot?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Selvarajah Premnath
el 13 de En. de 2021
Comentada: Star Strider
el 13 de En. de 2021
Hello, I am just beginner to matlab. Appriciate your help.
I attached the excel file for the x, y data.

0 comentarios
Respuesta aceptada
Star Strider
el 13 de En. de 2021
Try this:
D = readmatrix('Example.xlsx');
x = D(:,1);
y = D(:,2);
p = polyfit(x, y, 3);
yfit = polyval(p, x);
dp = polyder(p);
dyfit = polyval(dp,x(1));
bint = (yfit(1) - dyfit*x(1));
xinitslope = [x(1)-x(75), x(1)+x(75)];
yinitslope = dyfit*xinitslope + bint;
figure
plot(x, y)
hold on
plot(x, yfit, 'LineWidth',1.5)
plot(xinitslope, yinitslope, 'LineWidth',3)
hold off
grid
legend('Data', '3\circ Polynomial Fit', 'Initial Slope', 'Location','N')
text(xinitslope(1), yinitslope(1), sprintf('\\leftarrow Initial Slope = %7.2f',dyfit), 'HorizontalAlignment','left', 'VerticalAlignment','middle')
producing:

.
4 comentarios
Más respuestas (0)
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!