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

2 views (last 30 days)
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??..

Answers (1)

Walter Roberson
Walter Roberson on 8 Jun 2012
Change it to
fprintf(fid,'\n');
  1 Comment
sani ars
sani ars on 9 Jun 2012
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

Sign in to comment.

Categories

Find more on Text Analytics Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!