ads legend to plot

2 views (last 30 days)
Aaron Petersen
Aaron Petersen on 14 Apr 2022
Answered: Lokesh on 26 Sep 2023
Hallo, meinMatlab möchte diese Legende nicht darstsellen und ich finde den Fehler nicht.
Legendtitel = {'Messung Flussdichte','SIM Flussdichte','FEM Flussdichte','Analyse Flussdichte','Messung Abreiskraft','SIM Abreiskraft','FEM Abreiskraft','Analyse Abreiskraft'}
legend(Legendtitel)
Danke im Voraus!
Grüße, Aaron
  1 Comment
Aaron Petersen
Aaron Petersen on 14 Apr 2022
yyaxis left
ylabel('Flussdichte /mT')
plot(Magnete.AnzMagnete,Magnete.Flussdichte_mT,'-');
yyaxis right
ylabel('Abreiskraft /N')
plot(Magnete.AnzMagnete,Magnete.Abreiskraft_N,'-');
Und warum wird mir hier keine yAchsenbeschriftung ausgegeben?

Sign in to comment.

Answers (1)

Lokesh
Lokesh on 26 Sep 2023
Hi Aaron,
I understand from your query that your MATLAB code is not displaying the legend and ylabel correctly.
However, there are a few issues with the code you provided. The possible reasons for the issue and their fixes are mentioned below:
  • The “legend” and “ylabel” functions are used to display legend and plot for the previously plotted data series. So, ensure that you have plotted the data before calling the legend and ylabel function.
I have provided an example code snippet below that adds ylabel and legend to the plot:
yyaxis left
plot (Magnete.AnzMagnete,Magnete.Flussdichte_mT,'-');
ylabel('Flussdichte /mT')
yyaxis right
plot(Magnete.AnzMagnete,Magnete.Abreiskraft_N,'-');
ylabel('Abreiskraft /N')
Legendtitel = {'Messung Flussdichte', 'Messung Abreiskraft'}
legend(Legendtitel)
You can refer to the below mentioned documentation to know more about the usage of “ylabel” and “legend”:
Hope this helps in resolving the issue.
Best Regards,
Lokesh

Tags

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!