Multiple gassian fits in same plot

1 次查看(过去 30 天)
Fc Fc
Fc Fc 2018-2-9
编辑: Fc Fc 2018-2-9
Hi everyone, I need to fit a data set using a single and double gaussian fit. I wrote:
global fitresults
.
.
.
fitresults={}
.
.
.
eVcIpicco=eVc(:,1:20);
ckxfitIpicco=ckxfit(:,1:20);
[myfitga1,god1]= fit(eVcIpicco.',ckxfitIpicco.','gauss1');
[myfitga2,god2]= fit(eVcIpicco.',ckxfitIpicco.','gauss2');
fitresults{1}=myfitga1;
fitresults{2}=myfitga2;
figure (5)
plot5=figure (5);
set(plot5, 'Visible', 'off');
hold on;
h1=plot((fitresults{1}),'r-',eVcIpicco,ckxfitIpicco,'bo');
h2= plot( (fitresults{1}), 'r-' );
h3=plot((fitresults{2}),'g-');
xlabel('Energia (eV)');
ylabel('Conteggi relativi');
legend( [h1 h3], 'Dati', 'Gaussian 1 fit', 'Gaussian 2 fit');
title('Fit gaussiano primo picco');
axis([282 288 0 0.06]);
hold off;
But I get this error:
Error using horzcat
Dimensions of matrices being concatenated are not consistent.
Error in sp2sp3diff_Titantah (line 361)
legend( [h1 h3], 'Dati', 'Gaussian 1 fit', 'Gaussian 2 fit');
If I don't write the line
legend( [h1 h3], 'Dati', 'Gaussian 1 fit', 'Gaussian 2 fit');
I'get the plot but the legend isn't good and I cant' customize it, as you can see by the plot
Can somebody help me? Thanks

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Legend 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by