String array for creating titles for multiple Figures:

16 次查看(过去 30 天)
So I have a program that creates 8 figures, and I would like to create an array of strings where titles = ['bla1' 'bla2' ... 'bla8']; and then after each loop i have an index variable that will name that graph appropriately. The problem is it uses the index number for the first string. So the title of the graph in figure 1 is b, and the title of the graph in figure 2 is l and so on. I was wondering if there is anyway I can do something similar to the method I listed where I can do this with an array, or do I have to painfully name each graph individually? (which i would have no idea how to with my current set up.)
Btw i have 3 for loops where:
for a = 1:2
for b = 1:2
for c = 1:2
.
.
(some code for creating points)
.
.
figure;
subplot(2,1,1)
plot(SNR,PD,'-r*')
subplot(2,1,2)
plot(SNR,PFA,'-b*')
title(titles(indexOfTitle));
indexOfTitle = indexOfTitle + 1;
end
end
end
Thanks David

回答(1 个)

David
David 2012-2-28
I figured it out. All i had to do was replace the [] with {}. This changes the strings to cells so it reads the whole string instead part of it.

类别

Help CenterFile Exchange 中查找有关 Title 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by