Writing row vectors to file
    25 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
I am currently using the following scheme to write the row vectors Vec_A and Vec_B to a file:
fid = fopen('myfile.dat','wt');                                                    
fprintf(fid,'%f %f\n',Vec_A,Vec_B);                                             
fclose(fid);  
However, this writes the vectors as column vectors. How can I modify the above code to instead write them as row vectors, such that the values of Vec_A are the first row and the values of Vec_B are the second row?
0 comentarios
Respuestas (2)
  Ameer Hamza
      
      
 el 19 de Abr. de 2020
        Vec_A = 1:10;
Vec_B = 11:20;
fid = fopen('myfile.dat','wt');
fprintf(fid,'%f ',Vec_A);
fprintf(fid,'\n');
fprintf(fid,'%f ',Vec_B);
fclose(fid);
0 comentarios
  KSSV
      
      
 el 19 de Abr. de 2020
        M = [Vec_A; Vec_B] ; 
fid = fopen('MyFile.txt' , 'wt')
fprintf(fid, [repmat('%f\t', 1, size(M,2)) '\n'], M')                 
fclose(fid);
0 comentarios
Ver también
Categorías
				Más información sobre Cell Arrays 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!


