Headings for graphs generated in a loop

Hello,
Can anyone tell me how to go about having separate headings for graphs (and histograms) generated in a loop?
Thanks.

 Accepted Answer

myheadings = {'first title' 'seccond title' 'yet another title' 'and so one'};
for i = 1:4
plot(rand(1,10))
title(myheadings{i})
pause(1)
end

4 Comments

That looks like the business. Thankyou!
Actually... for some reason it's just putting myheadings(i) as the title for all of them. :(
Make sure to use curly braces
myheadings{i}
and that i is the index variable in your loop. Try the example.
Yep. My brackets weren't curly enough. Thanks again.

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Asked:

Tom
on 28 Jan 2013

Community Treasure Hunt

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

Start Hunting!