MATLAB Answers

Removing single quotations from a character array

9 views (last 30 days)
Frederick Koth
Frederick Koth on 18 Nov 2019
Commented: Walter Roberson on 18 Nov 2019
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.

Answers (1)

James Tursa
James Tursa on 18 Nov 2019
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
Walter Roberson on 18 Nov 2019
You can disp() the result to see it without the quotes.

Sign in to comment.


Translated by