replace a textline in file
Show older comments
Hi all,
I want to replace a text line with a user input (float number).
Text file :
OMT_INRT = { 0.0; 0.0; 0.0 }
PROJ_EPSI = { 0.0; 0.0; 0.0 }
NIT_RAXI = {0;0;0.0000006566506 }
NIT_VAXI = { 0; 0; 0 }
NIT_RANG = { 0; 0; 0 }
I want to replace '0.0000006566506' with a user input '0.003'. But what I am getting is ,
'NIT_RAXI = {0;0;0.003}006566506 }'
My program :
form = 'NIT_RAXI = {0;0;%0.3f}';
inp=input('replacement \n\n') ;
fid = fopen(filename,'r+');
for p=1:(n-1)
fgetl(fid);
end
fseek(fid, 0, 'cof');
f{i}= fprintf(fid, form,inp);
fclose(fid);
Note: all the terms in the left side of '=' are unique terms only. So i find the position of 'NIT_RAXI' ,.. that is at 'n', here n=3... and stored the whole file in f{i}
Thanks in advance
Accepted Answer
More Answers (0)
Categories
Find more on Characters and Strings in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!