How do I Remove Double Quotes from my Table?
Mostrar comentarios más antiguos
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 comentario
Csaba Noszaly
el 4 de Oct. de 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
>>
Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 28 de Ag. de 2018
0 votos
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 comentario
Mike Raymond
el 10 de Sept. de 2018
Categorías
Más información sobre Data Type Conversion en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!