ignore underscore so chars do not subscript

106 ビュー (過去 30 日間)
Alex
Alex 2015 年 3 月 18 日
コメント済み: Star Strider 2015 年 3 月 18 日
I am trying to play a movie where each frame has an associated file name. The file names are of the format "date_time_millisec.jpg" and I have them stored in a cell array. When I use the 'text' function in matlab to display the file name while playing the frame, it uses the '_' as a subscript command. So for example the file name is
20150314_185023_304
and this is what I want it to print as, but what it actually prints as is
20150314(subscript 1)85023(subscript 3)04.
(bear with me, this app does not allow the formatting of subscripts)
I am calling the function like this where frames{i} is the ith file name in my cell array 'frames'
text(x,y,frames{i});
Is there a way to force Matlab to print the underscore as an underscore instead of using it as a command to subscript?

採用された回答

Star Strider
Star Strider 2015 年 3 月 18 日
In the text function, specify the name-value pair 'Interpreter','none' to keep the underscores.
  2 件のコメント
Alex
Alex 2015 年 3 月 18 日
That worked thanks! I hadn't seen that name-value pair before. I can't find it in doc text even...
glad you knew about it!
Star Strider
Star Strider 2015 年 3 月 18 日
I just thought of another (but less convenient) way:
text(0.2,0.3, 'Filename: data\_1.mat')
Putting a backslant (\) in front of the underscore will work as well, but the backslant has to be inserted in the script, possibly using the strrep function.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by