Borrar filtros
Borrar filtros

writing data to a .txt file

1 visualización (últimos 30 días)
shanmukh
shanmukh el 23 de Mayo de 2013
Respondida: elham soltani el 3 de Nov. de 2014
i have 2 columns of data
a= { 1
2
3
4 }
b= { 5
6
7
8 }
i used
fprintf(f, '%d;%d;\n',[a b]);
i get output .txt file as
1;2;
3;4;
5;6;
7;8;
but i need data in this format
1;5;
2;6;
3;7;
4;8;

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 23 de Mayo de 2013
fprintf(f, '%d%d\n',cell2mat([a'; b']));
  2 comentarios
shanmukh
shanmukh el 23 de Mayo de 2013
i am getting an error
*Cell contents reference from a non-cell array object.
Error in cell2mat (line 43) cellclass = class(c{1});*
Azzi Abdelmalek
Azzi Abdelmalek el 23 de Mayo de 2013
if a and b are not cell array, use
fprintf(f, '%d%d\n',[a'; b']);

Iniciar sesión para comentar.

Más respuestas (1)

elham soltani
elham soltani el 3 de Nov. de 2014
what is f in fprintf(f, '%d%d\n',[a'; b']);??

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by