Azzera filtri
Azzera filtri

How can I save only one piece of data from the command window to a file?

1 visualizzazione (ultimi 30 giorni)
I am running a script to reject artifacts and I want to collate the number of rejections over each block/subject (there are a lot) into a single document. Besides doing it manually, is there a way to pull just the one number I want from each iteration into a file? This is what the output of one block from the function looks like in the command window:
detected 36 zvalue artifacts rejected 33 trials completely rejected 0 trials partially resulting 47 trials
For some reason the number of rejected trials aren't in any .mat file output, so basically I want an output that for every subject/block gives me: Rejected X trials completely
Thank you!

Risposta accettata

Iain
Iain il 11 Feb 2014
Before your loop:
fid = fopen(filename,'w');
In the loop:
fwrite(fid,['Rejected ' num2str(rejected) ' trials, and some more random text and variable to illustrate ' num2str(5) 10 13],'uint8');
After the loop
fclose(fid)
Then, open the file in a text editor. fprintf can be used instead of fwrite.
Alternatively, just log the answer to a result vector: Before the loop:
results = [];
In the loop:
results(end+1) = rejected;
  1 Commento
Mikael
Mikael il 11 Feb 2014
First, thank you for your input. Also, I'm pretty new to matlab so if this doesn't really make sense I apologize. I think that part of the issue is that 'rejected' isn't actually recognized as a variable. When I try to run either of your suggestions I get "Undefined function or variable 'rejected'." I looked in the script of the function I was using and I found a couple of lines that look like they are generating the output I am seeing in the command window: count_complete_reject = 0; (then later) count_complete_reject = count_complete_reject + 1; (and even later) fprintf('rejected %3d trials completely\n', count_complete_reject)
I don't know how to properly integrate the code so I can get a separate output file (I tried and got an 'undefined function or variable rejected' error) any further help would be huge.
Apologies if I'm super dense!

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by