How to separate characters in a cell array by commas
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Joel Olenga
el 5 de Jul. de 2022
Comentada: Joel Olenga
el 6 de Jul. de 2022
Hello I have the following code:
e = [3 0 -6];
n = length(e);
e_str = cell(1,n);
for i = 1:n
e_str(1,i) = {num2str(e(i))};
end
disp(e_str)
I'd like to separete the output with commas as follows:
{'3'} {','} {'0'} {','} {'-6'}
0 comentarios
Respuesta aceptada
Chunru
el 5 de Jul. de 2022
Wondering why you want that. But it can be done as follows:
e = [3 0 -6];
n = length(e);
e_str = cell(1,2*n-1);
for i = 1:n
e_str(1, 2*i-1) = {num2str(e(i))};
if i<n
e_str(1, 2*i) ={','};
end
end
disp(e_str)
6 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Spreadsheets en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!