How to get rid of double quotes from cell array

37 次查看(过去 30 天)
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 个评论
DGM
DGM 2023-1-3
编辑:DGM 2023-1-3
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'
Smithy
Smithy 2023-1-4
Thank you very much all the comments from Stephen23 and DGM.

请先登录,再进行评论。

采纳的回答

Smithy
Smithy 2023-1-4
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 个)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

标签

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by