.let format binary file
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Greetings and Regards
I have a .txt binary(force signal from left and right foot for example ) I want to know how to add it to the properties column(For example, columns 14 and 15 properties? thanks
0 commentaires
Réponse acceptée
Image Analyst
le 7 Août 2021
Try this (untested) to insert your values into columns 14 and 15 of the file:
% Open the file for reading in text mode.
inputFileID = fopen(fullInputFileName, 'rt');
% Open the output file for writing in text mode.
fullOutputFileName = 'Delete me.txt'; % Some temporary name
outputFileID = fopen(fullInputFileName, 'wt');
% Read the first line of the file.
textLine = fgetl(inputFileID);
lineCounter = 1;
while ischar(textLine)
% Print out what line we're operating on.
fprintf('%s\n', textLine);
% Read the next line.
textLine = fgetl(inputFileID);
% Insert binary values into columns 14 and 15.
outputTextLine = [textLine(1:13), binaryValue1, binaryValue2, textLine(14:end)];
% Write it out to the output file.
fprintf(outputFileID, '%s\n', textLine);
lineCounter = lineCounter + 1;
end
% All done reading all lines, so close the file.
fclose(inputFileID);
fclose(outputFileID);
% Copy new one over old one.
recycle on; % Recycle rather than delete permanently.
delete(fullInputFileName); % Delete old input file.
copyfile(fullInputFileName, fullOutputFileName); % Make new one have the same name.
delete(fullOutputFileName); % Delete temporary file.
13 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Text Data Preparation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!