Trying to learn how to add a threshold trigger and peak markers.

2 views (last 30 days)
%% 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!

Accepted Answer

Star Strider
Star Strider on 20 May 2022
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.
.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!