How to calculate the "Fit to estimation data validation" and the "MSE" between 2 curves and add it to the legend of the graphic?
8 views (last 30 days)
Show older comments
I have 2 types of plots that, in the end, hold all and the matlab returns a graphic with 8 curves. However there are 4 pars of curves that i want to know the fit data estimation and the MSE (each par is form by a "--" and "-" curve). Knowing those 2 parameters i want tha they apperar in front of the four last legnd topics like this: M(0.3) Fit:... MSE:...
%Função de transferência do par xF-xP
for f=[0.3 0.5 0.7 0.1]
for x=[0.3 0.5 0.7 0.1]
opt = stepDataOptions;
title('Comparação....'); %colocar um melhor título
legend('xF vs xP(0.3)','xF vs xP(0.5)','xF vs xP(0.7)','xF vs xP(0.1)','M(0.3)','M(0.5)','M(0.7)','M(0.1)');
ax = gca;
Nikhilesh on 31 Mar 2023
To add the fit data estimation and the MSE to the legend for each pair of curves, you can use the fit function (Fit curve or surface to data - MATLAB fit (mathworks.com)) to fit a curve to the data and then extract the fit data and the MSE.
You can use a loop to iterate through each pair of curves and fit a curve to the data using fit. Then you can extract the fit data and the MSE using func2str (Construct character vector from function handle - MATLAB func2str (mathworks.com)) and sum. Finally you can plot the fit curve with the legend using sprintf.
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!