Can array values be used in plot titles?

16 Ansichten (letzte 30 Tage)
Tom
Tom am 8 Nov. 2012
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?

Akzeptierte Antwort

José-Luis
José-Luis am 8 Nov. 2012
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)

Weitere Antworten (1)

Arthur
Arthur am 8 Nov. 2012
Use num2str and title.
  5 Kommentare
Arthur
Arthur am 8 Nov. 2012
You want to make titles from the array 'freq'? Then it should be
all_titles = arrayfun(@(x) {num2str(x)},freq);
Tom
Tom am 9 Nov. 2012
Many thanks Arthur & Jose-Luis.

Melden Sie sich an, um zu kommentieren.

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by