MATLAB Answers

i got an error as Warning: Ignoring extra legend entries

조회 수: 265(최근 30일)
vetri veeran
vetri veeran 25 Aug 2014
댓글: vetri veeran 25 Aug 2014
figure('name','flux vs current');
h1=plot(I1, flux1);
set(h1,'color','red','linewidth',3);
grid on;
hold all;
h2=plot(I2, flux2);
set(h2,'color','blue','linewidth',3);
grid on;
h3=plot(I3, flux3);
set(h3,'color','green','linewidth',3);
grid on;
legend([h1;h2;h3],'f1=30','f2=120','f3=400','fontsize',10);
title('flux vs current');
xlabel('current','fontsize',22);
ylabel('flux','fontsize',22);
how to overcome this. thanks in advance

  댓글 수: 0

로그인 to comment.

채택된 답변

Ben11
Ben11 25 Aug 2014
편집: Ben11 25 Aug 2014
What if you use:
legend([h1(1);h2(1);h3(1)],'f1=30','f2=120','f3=400','fontsize',10);
Just an idea; h1, h2 and h3 might contain multiple handles so selecting the 1st could solve the issue.

  댓글 수: 1

vetri veeran
vetri veeran 25 Aug 2014
I used the above code, even then also i am getting an error like this.Could you help me.

로그인 to comment.

추가 답변(1개)

Azzi Abdelmalek
Azzi Abdelmalek 25 Aug 2014
close all
clc
[I1,I2,I3]=deal(1:10);
flux1=sin(l1)
flux2=cos(I2)
flux3=sin(I3).^2
figure('name','flux vs current');
h1=plot(I1, flux1);
set(h1,'color','red','linewidth',3);
grid on;
hold all;
h2=plot(I2, flux2);
set(h2,'color','blue','linewidth',3);
grid on;
h3=plot(I3, flux3);
set(h3,'color','green','linewidth',3);
grid on;
hleg=legend('f1=30','f2=120','f3=400');
set(hleg,'fontsize',14)
title('flux vs current');
xlabel('current','fontsize',22);
ylabel('flux','fontsize',22);

  댓글 수: 1

vetri veeran
vetri veeran 25 Aug 2014
Thank you for your valuable answer. Now my program is running correct.

로그인 to comment.

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by