Trying to learn how to add a threshold trigger and peak markers.
조회 수: 2 (최근 30일)
이전 댓글 표시
%% Import Files
signal = 58; %chose column you're interested in in data
processedfilename = ['data1/LT1.txt'];
opts = detectImportOptions(processedfilename)
b = readtable(processedfilename,'ReadVariableNames',true);
LANK_ANG = b(5:end,signal);
pass = table2array(LANK_ANG);
processedfilename = ['data1/LT.txt'];
opts = detectImportOptions(processedfilename)
b = readtable(processedfilename,'ReadVariableNames',true);
LANK_ANG = b(5:end,signal);
pow = table2array(LANK_ANG);
processedfilename = ['data1/LT1.txt'];
opts = detectImportOptions(processedfilename)
b = readtable(processedfilename,'ReadVariableNames',true);
Z__Aaron_PneumaticAnkle_ExportedData_TB30_PassiveEvaluation__56 = b(5:end,signal);
pass = table2array(Z__Aaron_PneumaticAnkle_ExportedData_TB30_PassiveEvaluation__56);
%% Plot Data
signal = 58
figure;
plot(pass(:,1))
hold on
plot(pow(:,1))
plot(601,pass(601,1),'o')
plot(5749,pass(5749,1),'o')
This is my current script. I am currently trying to learn how to add threshold trigger that marks when the red line goes over .95 on the Y axis. I also am trying to find a way to put a marker on all of the peaks of the two lines. I am brand new to matlab and any help would be great. Thanks!
채택된 답변
Star Strider
2022년 5월 20일
Try something like this —
x = linspace(0,10,500);
red_line = sin(2*pi*x)*1.5;
trigger = find(diff(sign(red_line - 0.95)));
figure
plot(x, red_line, '-r')
hold on
plot(x(trigger), 0.95*ones(size(trigger)), 'xb', 'MarkerSize',10)
hold off
grid
Make appropriate changes to work with your code and data.
.
댓글 수: 2
Star Strider
2022년 5월 20일
As always, my pleasure!
With respect to the peaks, use findpeaks or islocalmax. (My apologies for not including those originally.)
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!