ads legend to plot
2 views (last 30 days)
Show older comments
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
Answers (1)
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”:
- ylabel: https://www.mathworks.com/help/matlab/ref/ylabel.html
- legend: https://www.mathworks.com/help/matlab/ref/legend.html
Hope this helps in resolving the issue.
Best Regards,
Lokesh
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!