MATLAB Answers


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;
Which gives the result:
But I need my answer to not include the single quotation marks that enclose the answer.


Sign in to comment.

1 Answer

Answer by James Tursa
on 18 Nov 2019 at 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

You can disp() the result to see it without the quotes.

Sign in to comment.