Plot title with variables on single line

31 ビュー (過去 30 日間)
Natasha
Natasha 2012 年 3 月 29 日
編集済み: resh 2017 年 7 月 23 日
I have the following line of code for a title on a plot:
title([IndexReturns.colheaders(1,k) '% move using' Days 'day rolling regression'])
But the title creates 4 seperate lines: 'variable, text, variable, text' instead of concatenating the text and variable values into a single line.
If I hardcode the title, it appears on 1 line.
Any ideas on how I remove the spacing?
Thanks in advance!
  1 件のコメント
Inmaculada Mohino
Inmaculada Mohino 2017 年 1 月 25 日
Thank you very much ;-)

サインインしてコメントする。

採用された回答

Jonathan Sullivan
Jonathan Sullivan 2012 年 3 月 29 日
My best guess if that IndexReturns.colheaders is a cell array. Try using curly brackets instead.
Example
title([IndexReturns.colheaders{1,k} '% move using' Days 'day rolling regression'])
  1 件のコメント
Natasha
Natasha 2012 年 3 月 29 日
That did it, thanks!

サインインしてコメントする。

その他の回答 (1 件)

resh
resh 2017 年 7 月 23 日
編集済み: resh 2017 年 7 月 23 日
Wanted to do the same thing. But had to add num2str to work it properly.
title([num2str(IndexReturns.colheaders{1,k}) '% move using' num2str(Days) 'day rolling regression'])

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by