How to do a curve fitting for a scatter plot?
101 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Gavin Lo-chindapong
el 23 de Abr. de 2018
Comentada: Gavin Lo-chindapong
el 25 de Abr. de 2018
Hi everyone,
I have a set of data and I want to plot a curve fitting along these scatter points. I try to use the curve fitting app provided in the MATLAB software but it's not really fitted. What are the codes that I should use to do a curve fitting for this scenerio? The curve doesn't need to fit every single point, an approximation would be fine for these fittings.
The desired curve should be something like on the attached photo.
clc;
close all;
clear all;
x_t = [0.969 0.951 0.938 0.944 0.932 0.926 0.932 0.944 0.951 0.975 0.975 1 0.963 0.957 0.932 0.914 0.87 0.858 0.821 0.772 0.698 0.673 0.66
];
y_t = [35.3 43.2 50.6 56.8 66 71.8 83.4 88 98.4 107 112 116 128 131 141 146 158 162 170 179 186 195 203
];
x_t1 = [1.008 1 0.992 0.983 0.933 0.924 0.933 0.958 0.975 0.992 1 1.008 1 0.975 0.966 0.95 0.941 0.899 0.933 0.908 0.891 0.882 0.849 0.79 0.765
];
y_t1 = [27.6 34.4 44 52.4 59.4 71.8 74.1 84.8 91.2 101 105 115 120 131 136 145 151 161 166 174 182 193 201 210 217
];
x_t2 = [1 0.85 0.9833 0.975 0.9667 0.975 0.9667 0.9583 0.9667 0.9833 0.9667 0.975 1 0.9667 0.975 0.9583 0.9417 0.933 0.8917 0.8333 0.875 0.85 0.8417 0.8167 0.8
];
y_t2 = [27.2 34 44.3 53 60.8 68.9 76 83.9 95.8 102.1 114 117 125 132 141 147 157 163 174 179 186 198 209 217 226
];
figure
plot(x_t,y_t, 'r*','Linewidth', 2);
xlabel('Signal intensity ratio');
ylabel('Temperature');
title('Intensity ratio calibration of 1:4% by mass');
legend('1:4%');
grid on;
figure
plot(x_t1,y_t1, 'g*','Linewidth', 2)
xlabel('Signal intensity ratio');
ylabel('Temperature');
title('Intensity ratio calibration of 1:20% by mass');
legend('1:20%');
grid on;
figure
plot(x_t2,y_t2, 'b*','Linewidth', 2)
xlabel('Signal intensity ratio');
ylabel('Temperature');
title('Intensity ratio calibration of 1:32% by mass');
legend('1:32%');
grid on;
Thanks!
0 comentarios
Respuesta aceptada
Rostislav Teryaev
el 24 de Abr. de 2018
Editada: Rostislav Teryaev
el 24 de Abr. de 2018
For approximation use polyfit. For interpolation use interp1. Also when doing approximation it may be helpful to change x and y. For example use not a
polyfit(x,y,7),
but
polyfit(y,x,7).
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!