Save a .dat file containing words and values
Afficher commentaires plus anciens
I know this topic has already been addresses, however none of the answers found in other questions could help me.
My problem is that I need to open a .dat file, change some of its values, and save it back. Probably the content in it of both characters and values makes it problematic to save it.
The save or dlmwrite do not work, and writematrix is not supported.
Does anyone know another way on how to save the file?
Thank you.
I attach the code I am using, the .txt from which I get the values to replace the existing ones, and a .txt version of the .dat file I have, since I cannot upload the original due to non supported file extension.
case_path='H:\Desktop\Samples\CASES\';
Samples=load(['Cases.txt']);
%%
N_an=10;
for ii=1:N_an
inp= textread([case_path,num2str(ii),'\INPUT SILENCE.dat'],'%s%*[^\n]');
inp{4}=num2str(0.045);
inp{21}=num2str(Samples(ii,1));
inp{22}=num2str(Samples(ii,2));
inp{23}=num2str(Samples(ii,3));
inp{26}=num2str(Samples(ii,3));
inp{27}=num2str(Samples(ii,4));
inp{28}=num2str(Samples(ii,6));
inp{88}=num2str(Samples(ii,7));
inp{89}=num2str(Samples(ii,8));
inp{90}=num2str(Samples(ii,9));
save([case_path,num2str(ii),'\INPUT SILENCE.dat'],'inp','-ascii');
dlmwrite([case_path,num2str(ii),'\INPUT SILENCE.dat'], inp)
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Text Files dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!