MATLAB Answers

0

Removing single quotations from a character array

Asked by Frederick Koth on 18 Nov 2019 at 1:26
Latest activity Commented on by Walter Roberson
on 18 Nov 2019 at 9:13
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 Comments

Sign in to comment.

1 Answer

回答者: James Tursa
2019 年 11 月 18 日 6:40

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 Comment

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

Sign in to comment.