How do I Remove Double Quotes from my Table?
Show older comments
I started with this seemingly simple problem as a way to learn some new skills in MatLab:
Given a list of names in a cell array, sort the list by the last name. My end-goal was to have a table with two columns, last and first name, sorted by last name. I think I'm close to a solution, but the table output includes double quotation marks. I'd like to understand a simple way of removing the quotation marks.
list = {'Barney Google','Snuffy Smith','Dagwood Bumstead'};
list = list';
list2 = split(list);
T = array2table(list2,...
'VariableNames',{'FirstName','LastName'});
T = sortrows(T,'LastName');
1 Comment
Csaba Noszaly
on 4 Oct 2024
starting at 2021a, Matlab has formattedDisplayText, whose output can be adjusted as needed:
>> mtx=["1" "2"; "alma" "körte"];
>> t=formattedDisplayText(array2table(mtx))
t =
" mtx1 mtx2
______ _______
"1" "2"
"alma" "körte"
"
>> disp(replace(t, '"', " "))
mtx1 mtx2
______ _______
1 2
alma körte
>>
Accepted Answer
More Answers (1)
Walter Roberson
on 28 Aug 2018
0 votes
I gave step by step method in https://www.mathworks.com/matlabcentral/answers/388602-remove-and-clear-things-in-a-table-for-presentation#answer_310244
1 Comment
Mike Raymond
on 10 Sep 2018
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!