How to change ylabels in a for loop

G
Gracesmith97 · Sep 1, 2020 · 1.8K views
Question
Hello everyone, I have a simple for loop to plot 7 different plots, but the ylabel should be different.   for k=1:7; figure bar(GAMMA_sta(k,:)) xlabel('Rock Types'); title( [ 'Statistics of Rocks', num2str(k)] ); end Anyone knows how to change ylabel for each plot in a for loop please let me know. Thanks. My 7 plots should have 7 different ylabels.
Expert Answer
Profile picture of Kshitij Singh
Kshitij Singh PhD Expert
Answered Nov 20, 2025

For example,

 

ylabel(sprintf('Plot #%d', k))

It would be easier if you indicated how you want the different ylabel to look.

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

Get a Free Consultation or a Sample Assignment Review!