필터 지우기
필터 지우기

Can array values be used in plot titles?

조회 수: 7 (최근 30일)
Tom
Tom 2012년 11월 8일
I'm really sorry I can't be more specific and include any code, but this is for an assignment and so it would be wrong to publish my code.
However, this is quite a generic question so I hoped this time it would not be a problem.
I have a figure with 5x2 plots on, and each of the ten plots correspond to a different frequency, which are generated by one entered value (not frequency).
Is it then possible to have those generated values (currently in an array) appear in the titles of each subplot?

채택된 답변

José-Luis
José-Luis 2012년 11월 8일
a = 1:10;
all_titles = arrayfun(@(x) {num2str(x)},a);
h = cell(1,10);
for ii = 1:10;
h(ii) = {subplot(1,10,ii)};
end
cellfun(@(x,y) set(get(x,'title'),'string',y),h,all_titles)

추가 답변 (1개)

Arthur
Arthur 2012년 11월 8일
Use num2str and title.
  댓글 수: 5
Arthur
Arthur 2012년 11월 8일
You want to make titles from the array 'freq'? Then it should be
all_titles = arrayfun(@(x) {num2str(x)},freq);
Tom
Tom 2012년 11월 9일
Many thanks Arthur & Jose-Luis.

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

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by