フィルターのクリア

Sign minus, not hyphen

80 ビュー (過去 30 日間)
Federico
Federico 2022 年 6 月 15 日
コメント済み: Walter Roberson 2023 年 11 月 2 日
Hello,
I must replace the hyphen - with the minus sign in figures, obtained with the plot command.
It should be − (UTF-16: 2212), not -.
How can I set it in the plot command?
Thank you

回答 (3 件)

KSSV
KSSV 2022 年 6 月 15 日
str = 'UTF−16:2212' ;
figure
title(str)

Chunru
Chunru 2022 年 6 月 15 日
編集済み: Chunru 2022 年 6 月 15 日
c1 = '−'; % (UTF-16: 2212), not -.
c2 = '-';
s1 = "both − and -"
s1 = "both − and -"
s2 = strrep(s1, c1, c2)
s2 = "both - and -"
contains(s1, c1)
ans = logical
1
contains(s2, c1)
ans = logical
0
subplot(121); title(s1)
subplot(122); title(s2)

Wilford Lie
Wilford Lie 2023 年 11 月 2 日
編集済み: Walter Roberson 2023 年 11 月 2 日
If the above suggestions do not work, try the followings:
neg = char( hex2dec('2212') ); % HTML UTF-8 heximal code for negative sign
mstr = strcat("UTF", neg, "8: 2212"); % or whatever strng you want
title(mstr); % or annotation(...)
^_^
  1 件のコメント
Walter Roberson
Walter Roberson 2023 年 11 月 2 日
mstr1 = "UTF" + char(0x2212) + "8: 2212"
mstr1 = "UTF−8: 2212"
mstr2 = compose("UTF%c8: 2212", 0x2212)
mstr2 = "UTF−8: 2212"
mstr3 = compose("UTF\210228: 2212")
mstr3 = "UTF−8: 2212"
Unfortunately you cannot use a plain \x2212 in this circumstances, because \x sequences are variable length and there is no termination character, so there is no way to tell it to stop parsing between the \x2212 and the 8 that follows.

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

カテゴリ

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

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by