Generate manual repeatable signal for matlab
1 view (last 30 days)
Show older comments
Jeroen Vermeulen
on 9 Jul 2020
Commented: Jeroen Vermeulen
on 20 Jul 2020
Dear matlab forum,
At this moment I'm evaluating a 'sample entropy' algorithm, that is used in heart and gait data currently.
I want to show the effect of sample frequency and time scales on the algorithms outcomes.
For this I want to create a manual function that can be repeated, that resembles the gait flexion angle of the knee.
This function must look like the negative part of a sinusoid (1Hz), amplitude -5, followed by the positive part of a sinusoid (2Hz) amplitude +1.
I should be able to use this function in a matlab script. At this point I'm quite a novice on this topic, and I want to see what your recommendations for designing such a function for matlab would be. I added a sketch to give a better idea on the curve of the function.
I look forward to seeing your answer(s).
Greetings,
Jeroen
0 Comments
Accepted Answer
Alan Stevens
on 9 Jul 2020
Like this?
dt = 0.01;
tf = 1.5;
n = tf/dt + 1;
for i = 1:n
t(i) = (i-1)*dt;
y(i) = wave(t(i));
end
plot(t,y),grid
function y = wave(t)
w1 = 2*pi; % frequency rads/sec
w2 = 4*pi; % "
A1 = -5; % amplitude
A2 = 1; % "
if t<1
y = A1*sin(w1*t);
else
y = A2*sin(w2*t);
end
end
More Answers (0)
See Also
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!