MATLAB Answers

Removing single quotations from a character array

12 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.

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.

Community Treasure Hunt

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

Start Hunting!

Translated by