Need help to save data from getkey into the file by using fprint
Show older comments
Hi guys
I am writing a code to save data from the keyboard after presenting some photos to the participants.
1- I need to save the data including the information of the participants in line one
2- in line two I need to save the id for the photo being presented
3- within a tab I need to save the category for the photo being presented
4- within another tab in line two i need to save the participant's answer to the photo which would be a single key press through getkey
5- and also within another tab space I need to save the duration for the answer
I have already defined all of the above mentioned as :
fid: handle for the file fiel: file for the name of the photo being presented T: the category for the file A: to keep the getkey() result R: to keep the time duration for the answer
My question now is how to save them all correctly in a file using fprint?
Thank you for your help
Accepted Answer
More Answers (2)
Matt Kindig
on 2 Jan 2013
Hi Maliheh,
Based on what you have specified above, I think this will work:
%note that you will need to define the participants_info and photo_id variables, which you have not yet specified.
fout = fopen('/path/to/output_file.txt', 'wt');
fprintf(fout, '%s\n', participants_info);
fprintf(fout, '%d\t%s\t%s\t%s', photo_id, T, A, R);
fclose(fout);
maliheh
on 2 Jan 2013
0 votes
Categories
Find more on Low-Level File I/O in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!