How to make figure title from multiple sources when looping

2 次查看(过去 30 天)
The following script makes 6 figures with the headlines "Scenario X" where X=1,2,3. I want to include also "Vars2" in the title, because now you don't know which Vars that is reported in the figures. I want 6 different titles instead of only 3.I hve tried putting Vars2 next to Scenario in the title line, but it does not work.
Scenario={'Scenario 1', 'scenario 2', 'scenario 3'};
a = rand(1,2,3);
b= rand(1,2,3);
Vars = {a,b};
Vars2 = {'a', 'b'}
for j =1:2;
for i = 1:3;
Var=Vars{j}
figure, title(Scenario{i});
hold on
plot(Var(:,:,i));
end
end
Any ideas on how to fix this?

采纳的回答

Iain
Iain 2013-6-21
title([Scenario{i} ' Variable: ' num2str(j)]);
That should do it, and if not, try using Scenario(i) instead.

更多回答(0 个)

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by