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

2 vues (au cours des 30 derniers jours)
Marshall Harkrider
Marshall Harkrider le 20 Mai 2022
Commenté : Star Strider le 20 Mai 2022
%% 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!
  1 commentaire
Marshall Harkrider
Marshall Harkrider le 20 Mai 2022
Please let me know if there is any missing info I could provide that would be of assistance.

Connectez-vous pour commenter.

Réponse acceptée

Star Strider
Star Strider le 20 Mai 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.
.
  2 commentaires
Marshall Harkrider
Marshall Harkrider le 20 Mai 2022
Thank you!!
Star Strider
Star Strider le 20 Mai 2022
As always, my pleasure!
With respect to the peaks, use findpeaks or islocalmax. (My apologies for not including those originally.)

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by