Question
I am plotting a cosine wave, a sine wave and an amplified sine wave (in that order) on a single plot (figure window). However, I would like my legend to name and display only the cosine wave and the amplified sine wave. The figure itself should display all the plots i.e. cosine, sine, amplified sine.
Expert Answer
Kshitij Singh
PhD Expert
Answered Aug 23, 2026
To show only certain graphics in a legend, explicitly place their handles at the beginning of the call to legend, e.g:
x = -pi:pi/20:pi; h1 = plot(x,cos(x),'-ro'); hold on h2 = plot(x,sin(x),'-.b'); h3 = plot(x,2*sin(x),'-*k'); legend([h1 h3],'cos(x)','2*sin(x)')
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related matlab Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →