-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSaveIgorText_Average.m
More file actions
53 lines (45 loc) · 1.34 KB
/
SaveIgorText_Average.m
File metadata and controls
53 lines (45 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
function SaveIgorText_Average(handles)
global gSaveDataAve gmSEQ
%global gScan
%name=regexprep(gmSEQ.name,'\W',''); % rewrite the sequence name without spaces/weird characters
%File name and prompt
B=fullfile(gSaveDataAve.path, gSaveDataAve.file);
%file = strcat(name, gSaveDataAve.file);
%Prevent overwriting
mfile = strrep(B,'.txt','*');
mfilename = strrep(gSaveDataAve.file,'.txt','');
A = ls(char(mfile));
ImgN = 0;
for f = 1:size(A,1)
sImgN = sscanf(A(f,:),strcat(string(mfilename), '_%d.txt'));
if ~isempty(sImgN)
if sImgN > ImgN
ImgN = sImgN;
end
end
end
ImgN = ImgN + 1;
file = strrep(gSaveDataAve.file,'.txt',sprintf('_%03d.txt',ImgN));
final= fullfile(gSaveDataAve.path, file);
%Save File as Data
organized = [gmSEQ.SweepParam(~isnan(gmSEQ.signal(1,:)))];
%check if to record photodiode voltage data
pd=1;
if gmSEQ.measPD
if strcmp(gmSEQ.meas2,'PD0')
pd = pd+1;
end
if strcmp(gmSEQ.meas3,'PD1')
pd = pd+1;
end
end
Ndata = gmSEQ.dataN*pd;
for i = 1:Ndata
organized = [organized; gmSEQ.signal_Ave(i, ~isnan(gmSEQ.signal(i,:)))];
end
fid = fopen(string(final),'wt');
fprintf(fid,'IGOR\nWAVES/D/O sweep,sig(%d) \nBEGIN\n', gmSEQ.dataN);
fprintf(fid, [repmat('%d ', [1, Ndata + 1]), '\n'], organized);
fprintf(fid, '\nEND\n');
fclose(fid);
handles.textFileNameAve.String = file;