I would like to store a title of a plot as a variable because of loop programming.
The running variable is P = M_f1. M_f1 is a matrix. But I just want to show the actual name (M_f1) with the variable P in the title.
-> title (P)?
Anyone have an idea?

댓글 수: 4

KSSV
KSSV 2020년 5월 28일
How many variables you have? How you are accessing the variable? Better show us the code how you are plotting...
Mohammad Sami
Mohammad Sami 2020년 5월 28일
Can you also clarify your question. I don't understand what you mean by
"But I just want to show the actual name (M_f1) with the variable P "
KSSV
KSSV 2020년 5월 28일
P = 'M_f1' ;
title(P)
Mepe
Mepe 2020년 5월 28일
Thanks for your answers.
Here the example code:
for i=1:1:12
if i==1
P=M_f1
elseif i==2
P=M_f2
elseif i==3
P=M_2f1
elseif i==4
P=M_2f2
else
P=M_3f1
end
f = figure(i);
set(f, 'Units', 'normalized', 'Position', [0.1, 0.1, 0.6, 0.3]);
axes1 = axes('Parent',f);
hold(axes1,'on');
[C,h]=contourf(P,15);
box(axes1,'on');
axis(axes1,'tight');
set(axes1,'BoxStyle','full','Layer','top');
colorbar(axes1);
title(???????)
end
Various plots are to be created via a loop. I wanted to use the variable P for the declaration. Depending on the run variable, the corresponding matrix (M_f1, M2f1 ...) is now transferred.
Now wants the corresponding title to be displayed for the various plots via the variable. I would also want to use P here. I don't want to see the numerical values there, but the name of the variable (Title = M_f1, M2f1 ...).
I hope I could explain it better now :-).
Thanks a lot.

댓글을 달려면 로그인하십시오.

 채택된 답변

Ameer Hamza
Ameer Hamza 2020년 5월 28일

1 개 추천

Run this example
titles = {'title1', 'title2', 'title3'};
for i=1:3
figure(i)
plot(rand(1,10));
title(titles{i});
end

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Graphics Performance에 대해 자세히 알아보기

태그

질문:

2020년 5월 28일

댓글:

2020년 5월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by