add column to file with dlmwrite

3 visualizaciones (últimos 30 días)
Marisabel Gonzalez
Marisabel Gonzalez el 5 de Abr. de 2019
Comentada: Walter Roberson el 12 de En. de 2023
Hello, is there anyway to add a column to an existing file using dlmwrite?
I've tried to transpose it to add lines instead and later convert it to columns again but I get the error " FILENAME must be a character vector "
A = [0.23;0.44;0.65;0.12];
A = A';
oldfile = dlmread('testfile1.txt');
oldfile = oldfile';
dlmwrite(oldfile,A,'-append','newline','pc','delimiter',' ')

Respuestas (1)

Walter Roberson
Walter Roberson el 5 de Abr. de 2019
Only by rewriting the entire file.
  4 comentarios
Devikrishna
Devikrishna el 12 de En. de 2023
My matrix is in the form 39×39 I want to add a column using dlmwrite and make 39× 40
Walter Roberson
Walter Roberson el 12 de En. de 2023
The way that text files are designed in Windows, Mac, and Linux makes it impossible to add additional information to a row without rewriting the entire file. That applies not just to dlmwrite but also to writematrix and to using excel.
You need to use a system like I posted the code for, of reading the existing file, adding the new column in memory, and writing out the revised content

Iniciar sesión para comentar.

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by