How to change a specific column of a text file and save as a difrent file?

2 visualizaciones (últimos 30 días)
I have a text file which contains data about GPS data, i need to make some addition or extraction of 5.column of the text file and save as whole file as a diffrent file. I have tried this code but i need to ignore until # mark, here my try:
fid=fopen(Datafile);
Data=textscan(fid,'%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s','treatAsEmpty','NaN');
fclose(fid);
h=Data{6};
prompt={'Enter the N(m) value'};
name = 'Geoid Height';
defaultans = {'25.5'};
options.Interpreter = 'tex';
N = inputdlg(prompt,name,[1 40],defaultans,options);
N=cell2mat(N);
N=str2num(N);
H=h-N;
H=num2cell(H);
H(cellfun(@isnan,H)) = {[]};
folder_name=handles.folder_name;
dosya_adi=sprintf('%s-%s.txt','A','B');
out_name=(fullfile(folder_name,dosya_adi));
if exist(out_name,'file')==2
delete(out_name);
end
fid=fopen((out_name),'w');
for i=1:length(Data{1})
fprintf(fid,' %s%16s%16s%16s%11.3f%13s%13s%13s%9s%9s%9s%10s%10s%10s\r\n',...
Data{1}{i},Data{2}{i},Data{3}{i},Data{4}{i},H{i},Data{6}{i},Data{7}{i},Data{8}{i},...
Data{9}{i},Data{10}{i},Data{11}{i},Data{12}{i},Data{13}{i},Data{14}{i});
end
fclose(fid);

Respuestas (0)

Categorías

Más información sobre Text Data Preparation en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by