how to delete column from text file without loading it into a matrix first

조회 수: 2 (최근 30일)
sani ars
sani ars 2012년 6월 8일
I have the code as follows:
fid = fopen('5_prcnt_noised_iono_train_data.txt','w+');
for i = 1:Ntrain_data
fprintf(fid,'\n%6.2f',noised_train_data(i));
for j = 1:Nof_noised_train_feat
fprintf(fid,'\t%6.2f',noised_train_data(i,j));
end
end
in this , I have write the train data into a text file from train_data matrix.... The problem is, when writing the data in the text file,it also print an extra first column in the start of each row....and I don't want this extra first column....
I have to delete that column but the format of fprintf func does not allow me to do this.....
There is need to make change in the 3rd line of code:
fprintf(fid,'\n%6.2f',noised_train_data(i));
this syntax add an extra first column in each row.....
how to fix it??..

답변 (1개)

Walter Roberson
Walter Roberson 2012년 6월 8일
Change it to
fprintf(fid,'\n');
  댓글 수: 1
sani ars
sani ars 2012년 6월 9일
but when I open the text file it doesn't show me the next row in new line it continues to the same row.. Although, when I open this text file via MATLAB editor it shows me the next row in new line correctly....
I also wants the same with when I open the text file without MATLAB editor.............
Actually, I have to use this text file further in my code so, I need to keep the data in an arranged format

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Text Analytics Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by