Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
This code tests rising edges plus the time they occured, but it still give me errors, plus it has to check the file line by line.....PLEASE HELP
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
function [l,c,n] = find_edges(s , a, file)
fid = fopen(file, 'r'); disp('found');
v1 = [0 0 0];
v2 = [0 0 0];
v3 = [0 0 0];
b = false;
seq_dur=0;
seq_dur = seq_dur + 1;
act_off = 0;
last_t = 1 + act_off - seq_dur; l = v1; c = v2; n = v3; frewind(fid); N=fread(fid, 16, 'double'); length(N) N(1:10) assignin('base','helpme',N)
% Set the threshold to 3.5 V.
threshold = 3.5;
offsetData = [fid(2:end); NaN];
risingEdge = find(fid < threshold & offsetData > threshold);
fallingEdge = find(fid > threshold & offsetData < threshold);
hold on
plot(time(risingEdge), threshold, 'rx');
plot(time(fallingEdge), threshold, 'go');
hold off
pulseIndices = zeros(length(risingEdge) * 2, 1); pulseIndices(1:2:end) = risingEdge; pulseIndices(2:2:end) = fallingEdge; pulseTimes = diff(time(pulseIndices));
%c(2) = mult; %n(2) = mult;
while ~feof(fid) swap(l, c); swap(c, n); fread(fid, 'double', 16) t = mod(c(0), seq_dur) - 1; n(2) = mult;
if(~b && l(2) > 0.4 && c(2) > 0.9 && n(2) > 1.0)
if(~b)
rel_delta = l(1) - last_t;
disp( l(1), ' ' , rel_delta , ' ', (t + (l(1) - l(1))) , ' ', l(2) , ' ');
last_t = l(1);
if(rel_delta > (seq_dur + 3) || rel_delta < (seq_dur - 1))
disp( 'bad delta ');
disp( ' ');
disp( rel_delta );
disp( sprintf('\n'));
if(~cont)
break;
end
end
end
b = true;
elseif(b && l(2) < 0.8 && c(2) < 0.5 && n(2) < 0.5) disp(t + (c(1) - c(1))); disp(sprintf('\n')); b = false;
end
end
b = true; t=2; if(b) disp(t) disp(sprintf('\n')) end
end
1 Kommentar
Walter Roberson
am 9 Jul. 2012
What errors are you observing? Is there an error message?
Why is it a problem if the code checks the file line by line?
What is swap() ?
Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!