is there a way to go to the line above using fprintf function ?

6 vues (au cours des 30 derniers jours)
Reema Alhassan
Reema Alhassan le 13 Juil 2018
Modifié(e) : Diwakar le 13 Juil 2018
I'm writing on a csv file and I'm writing column by column for example here :
for i = 1 : length(col)
fprintf( fid, '%s\n', matrix{i});
end
I used this to make new line after each iteration I need to go to the same place before entering the loop
for example the output after the loop in csv will be 1 22 33 45 6 8 9 I need the pointer to go back to element 1 because what I need to do is to make another column near this column does anyone know how to do this?
Thank you

Réponses (1)

Diwakar
Diwakar le 13 Juil 2018
Modifié(e) : Diwakar le 13 Juil 2018
Okay so your idea is to move the cursor to a different part of your file after a write job. So, for this I would suggest you to look into the ftell function of MATLAB. The link to the documentation is : https://www.mathworks.com/help/matlab/ref/ftell.html?searchHighlight=ftell&s_tid=doc_srchtitle
This function will give you the current location of the cursor after the first write. Then you can use the fseek function to move the cursor to the desired location. The documentation for which is : https://www.mathworks.com/help/matlab/ref/fseek.html?searchHighlight=ftell&s_tid=doc_srchtitle
Hope this helps Cheers!

Catégories

En savoir plus sur Data Import and Export dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by