How to get rid of double quotes from cell array

hello, everybody
I would like to get rid of double quotes from cell array. The Output will be cell array without double quotes.
Is it possible to remove it?
% For example I have a 8×1 cell array "exp". How to get rid of double quotes of m and L and c ?
exp = {"m", 10, 20, "L", 0, "c" 0, 0}';
% Output will be cell array of {m, 10, 20, L, 0, c 0, 0}
exp = strrep(exp(:,1),'"',''); % error Occures.

댓글 수: 3

Stephen23
Stephen23 2023년 1월 3일
편집: Stephen23 2023년 1월 3일
"How to get rid of double quotes of m and L and c ? exp = {"m", 10, 20, "L", 0, "c" 0, 0}'; Output will be cell array of {m, 10, 20, L, 0, c 0, 0}"
How did you check if the text data really contain quotation characters? Most likely you are confusing how data is displayed with what data is actually stored in memory, and there are no quotation characters in your text. In which case, what are you actually trying to achieve?
It appears you have a mix of strings and numeric scalars. There are no double quotes in the strings. As Stephen says, that's how strings are displayed. Strings are created and displayed using double quotes. Character arrays are created and displayed using single quotes.
mystring = "This string contains -->""<-- one double quote"
mystring = "This string contains -->"<-- one double quote"
mychar = 'This char vector contains -->''<-- one single quote'
mychar = 'This char vector contains -->'<-- one single quote'
Thank you very much all the comments from Stephen23 and DGM.

댓글을 달려면 로그인하십시오.

 채택된 답변

Smithy
Smithy 2023년 1월 4일

0 개 추천

Thank you very much all the comments from Stephen23 and DGM.
Yes, I found out that my data are mixed with strings and numeric scalars, it is just double quotes displaying. (not real)
So I modify the numeric to string using below line. Then the double quotes disappear.
Thank you very much for helpful comments. It gives me huge helps.
exp = cellstr(string(exp));

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Variables에 대해 자세히 알아보기

제품

릴리스

R2022a

태그

질문:

2023년 1월 3일

댓글:

2023년 1월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by