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

조회 수: 9 (최근 30일)
Reema Alhassan
Reema Alhassan 2018년 7월 13일
편집: Diwakar 2018년 7월 13일
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

답변 (1개)

Diwakar
Diwakar 2018년 7월 13일
편집: Diwakar 2018년 7월 13일
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!

카테고리

Help CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by