MATLAB Answers

Removing single quotations from a character array

7 ビュー (過去 30 日間)
Frederick Koth
Frederick Koth 2019 年 11 月 18 日
コメント済み: Walter Roberson 2019 年 11 月 18 日
So I have this code:
function [myRes] = getAsDMS(angle)
angle = 20.5;
d = floor(angle);
m = floor((angle - d) * 60);
s = round(((angle-d)* 60 - m)*60);
str = [num2str(d), '°' , num2str(m),'''', num2str(s), '"'];
myRes = str;
end
Which gives the result:
'20°30'0"'
But I need my answer to not include the single quotation marks that enclose the answer.

  0 件のコメント

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

回答 (1 件)

James Tursa
James Tursa 2019 年 11 月 18 日
Your answer does not include the bounding single quotation marks ... that is just a display artifact for how MATLAB prints character strings to the screen. The myRes variable only includes the characters between the bounding single quotation marks.

  1 件のコメント

Walter Roberson
Walter Roberson 2019 年 11 月 18 日
You can disp() the result to see it without the quotes.

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

Community Treasure Hunt

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

Start Hunting!

Translated by