Mino1234
Mino1234

Reputation: 107

How to remove " from the whole table?

Lets get a simple table that has 2 columns A and B. Values of this table look like:

"ABCD" "123"
"EFGH" "456"
"IJKL" "789"

And here I need to remove all "", so I will get only values between "". Is it some property of table, that it gives strings into ""? I am not able to remove them. Is there just a different approach to work with strings in tables?

Upvotes: 0

Views: 231

Answers (1)

Sardar Usama
Sardar Usama

Reputation: 19689

You're using a string array to make that table and hence the "s.
Use categorical to get rid of them in your table.

An example:

%Assuming you have the data in the form of a string array, so creating a string array
S= string({'ABCD' '123';'EFGH' '456'; 'IJKL' '789'})

%S = 
%
%  3×2 string array
%
%    "ABCD"    "123"
%    "EFGH"    "456"
%    "IJKL"    "789"

T = table(categorical(S(:,1)),categorical(S(:,2)))

%T =
%
%  3×2 table
%
%    Var1    Var2
%    ____    ____
%
%    ABCD    123 
%    EFGH    456 
%    IJKL    789 

Upvotes: 3

Related Questions