Legend ommit first plot title in multiple plots
Ältere Kommentare anzeigen
I am attempting to create a comparison plot between the original fuzzified data and a fitted version. However, the label for the first plot ('Data #1') is missing from the legend. I have tried adjusting the position of the 'hold on' command, but have been unable to resolve the issue."
clf, figure('Position',[1 1 600 300],'Units','pixels');
hold on
for i=1:length(uCenters)
fo = fitoptions( ...
'Method','NonlinearLeastSquares', ...
'StartPoint',[1 uCenters(i)], ...
'Lower',[0 -Inf]);
ft = fittype('gaussmf(x,[a,c])','options',fo);
f = fit(uSrt,uFCM(i,:)',ft);
H1 = plot(uSrt',uFCM(i,:),'--g');
H1.DisplayName = sprintf('Data #%d',i);
H2 = plot(f,'b');
H2.DisplayName = sprintf('Fuzzy #%d',i);
end
hold off, grid on, legend('Location','eastoutside','Box','off')
xlim([min(uSrt) max(uSrt)])
ylim([0 1.1])
xlabel('Voltaje (V)'), ylabel('Nivel de pertenencia')
title('Voltaje fuzzificado ajustado a curva gaussiana')

1 Kommentar
dpb
am 20 Mai 2023
Without data to check against, it's hard to debug exactly, but I'd venture that the first data set are NaN.
Your code also overwirtes the plot and fit handles every pass through the loop so you can't inspect the results of each loop independently after the loop completes; only by setting breakpoint and using the debugger as is. It would be better to save an array of handles, then you could see each result more simply...
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Interpolation finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

