.let format binary file

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

 Accepted Answer

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 Comments

Thank you for your guidance.
But if you have downloaded the file I sent, for example, I want to add a power signal related to for example control14.rit, control 14.let, to columns 14 and 15. Attributes. I do not know how to do this and its command in MATLAB software What is it ???
Thanks a lot
In other words, how to stretch the binary file in the text into a matrix
Sorry I don't know what you want. You're not giving any example of the desired output. What I did was to insert something into columns 14 and 15 of the existing file. on a line-by-line basis I thought that's what you wanted but apparently not. Sorry.
The input file given has two space-delimited columns. The first column appears to be 64 hex digit representation of SHA256 sums of something. The second column appears to be plain text.
If you want to convert the hex to binary, that could be done, but you need to define how you want it converted. Do you want each nibble to become a column? Do you want each pair of two hex characters to become a column, producing 32 columns? Do you want each group of four hex characters to become a column, producing 16 columns?
Hi
No I do not mean I only want lines in .let, .rit format from this .txt file.
I already have 13 attribute columns for each person and I want to add these two attributes (.let, .rit) related to each person and add attributes to column (14 and 15). For example. Information about the person is control 14.let in the text file on line 4 and control 14.rit in the text file on line 190. I want to add these two lines to the information about control person 14. I already had 13 feature columns, and now I want to put column 14 information about control 14.rit and column 15 information about control 14.let. And do the same for the rest of the people. But I do not know how to write the MATLAB command ???
I hope you understand what I mean. Thank you
The lines of the file that you indicate do not have the data you are talking about.
Line 9 of the file has
a5ba09f2fb1c481ddeb6a836ea01675895f699aebedd802296a3b1e2f1a1532e control14.rit
Do I understand correctly that you would then want to insert
a5ba09f2fb1c481ddeb6a836ea01675895f699aebedd802296a3b1e2f1a1532e
in column 15 ? And because of the
be6d14e118cd8b85ef3b6f25ced99ada27b91f7f3e677f46491e9bf4589b92b6 control14.let
much further down in the file, in column 14, you would want to insert
be6d14e118cd8b85ef3b6f25ced99ada27b91f7f3e677f46491e9bf4589b92b6
?
If so, then what column of the current file would have the key information "control14" that is needed to match against?
Yeah Al that sounds pretty crap to me, Looks like Hunt 13 aint for me either. Your post is completely correct. The file contains complete information and the 13 features mentioned in the .ts section. (control 14.ts)
I already had 13 feature columns, and now I want to put column 14 information about control 14.rit and column 15 information about control 14.let. And do the same for the rest of the people. But I do not know how to write the MATLAB command ???
I generally got the data from the physionet site. (Section Gait in Neurodegenerative Disease Database) in this site https://physionet.org/about/database/
thanks so much
??????????
I have no idea who Al is, or why you think they posted about a crap situation ??
So far you have not answered my question of which column in your existing array (the one you are trying to add columns to) has the name such as "control14" that has to be matched against in order to know which row to insert data into.
Yeah, or what "Hunt 13" means. Someone ("Al") probably deleted his reply after @NEGAR MONFARED replied to it.
You're free to start your own answer, Walter, if you want. I'm bowing out since I can't figure out what he wants and is not posting a desired output. All I know is that the first line of the text file he posted is
1f12c0a2aad75eb1310fbfa29b800a0c970de8cf0cc045b833f60c642fe723a8 control14.hea-
and the columns are
123456789012345678901234567 etc.
on a character-by-character basis. (Or like you said there are only two columns if you're looking at whole words separated by white space.)
So, assuming we have more than two columns, column 13 is "e" and column 14 is "b" so I gave code to put two logical values after the "e" and before the "b" which gives two new characters for columns 14 and 15. Evidently that is not what is wanted, and since I can't even figure out what is wanted, I'm quitting.
I think they are looking for the whole hex, and that the task is just to match up the .let and .rit names in the second column to the existing rows and put the entire hex into column 14 or 15 of the array. Not difficult if you know which column in the line has the "control14" (or whatever) header.
I do not know where to find out that what column of the current file would have the key information "control14" that is needed to match against. and i don not khnow what you say ?
The only thing I know about the main feature information is the 13 feature columns I mentioned in .ts files.
for example this is file about control14.ts that have 249*13 .I want to add control14.let in column 14 and control14.rit in column 15.
I have just the .rit and .let file in binary format and i get the other features from .ts file .I want to convert .let, .rit files to non-binary format and put them in columns 14 and 15 along with other features.dear walter You understand what I mean??

Sign in to comment.

More Answers (0)

Products

Release

R2019a

Community Treasure Hunt

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

Start Hunting!