Break title into multiple lines? Part 2

151 Ansichten (letzte 30 Tage)
alpedhuez
alpedhuez am 30 Nov. 2020
Bearbeitet: alpedhuez am 30 Nov. 2020
shows
title({'You can do it','with a cell array'})
works. Now supppose I have two string variables title1 and title2. How can one apply this method? I tried
title({[title1] [title2]})
But this does not seem to work.

Akzeptierte Antwort

Bjorn Gustavsson
Bjorn Gustavsson am 30 Nov. 2020
This works:
title1 = string('The first title-row');
title2 = string('Some Rosetta stonery');
title3 = string('Den sista titelraden');
plot(randn(5))
title({title1,title2,title3})
Note the ','-separation. You can also use vertical concatenation - i.e. replace ',' with ';'.
HTH

Weitere Antworten (1)

Ameer Hamza
Ameer Hamza am 30 Nov. 2020
Bearbeitet: Ameer Hamza am 30 Nov. 2020
What you have already wrote is the correct syntax
title1 = 'You can do it';
title2 = 'with a cell array';
title({[title1] [title2]})
You can also write it like this
title({title1 title2})
  2 Kommentare
alpedhuez
alpedhuez am 30 Nov. 2020
char, string, cell,...
alpedhuez
alpedhuez am 30 Nov. 2020
Bearbeitet: alpedhuez am 30 Nov. 2020
Yes thank you. Just to acknowledge the first answer.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Data Type Identification finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by