Legend ommit first plot title in multiple plots
显示 更早的评论
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 个评论
dpb
2023-5-20
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...
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Interpolation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

