Azzera filtri
Azzera filtri

I have attached a fig file in which I have used 3 legends for upper, middle and lower curve, respectively. Actually, there are six lines in each curve but I want each curve to look like a single line. How is it possible using fig file.

1 visualizzazione (ultimi 30 giorni)
I have attached a fig file in which I have used 3 legends for upper, middle and lower curve, respectively. Actually, there are six lines in each curve but I want each curve to look like a single line. How is it possible using fig file.

Risposta accettata

Star Strider
Star Strider il 4 Lug 2019
Try this:
I = openfig('comp25.fig');
Ax = gca;
lgnd = Ax.Legend;
Lines = findobj(Ax,'Type','line');
for k1 = 1:fix(numel(Lines)/6) % Consider 6 ‘Lines’ In Each Iteration
for k2 = 1:6
X(k2,:) = Lines(k2+(k1-1)*6).XData; % Get ‘X’ Values For This Set
Y(k2,:) = Lines(k2+(k1-1)*6).YData; % Get ‘Y’ Values For This Set
end
Xm(k1,:) = X(1,:); % X-Vector (For Plot)
Ym(k1,:) = mean(Y); % Y-Vector (For Plot) - Uses ‘mean’, ‘median’ Or Others May Be Appropriate As Well
end
figure
semilogy(Xm', Ym')
grid
legend(Ax.Legend.String)
xlabel(Ax.XLabel.String)
ylabel(Ax.YLabel.String)
It is difficult to determine what you want for each single line, so here I took th mean of each consecutive group of 6 Line objects.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by