필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
Mikael
Mikael 2014년 2월 11일
댓글: Mikael 2014년 2월 11일
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!

채택된 답변

Iain
Iain 2014년 2월 11일
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
Mikael
Mikael 2014년 2월 11일
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!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by