How to make figure title from multiple sources when looping

조회 수: 2 (최근 30일)
Karl
Karl 2013년 6월 21일
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