Create nonlinear trend via trapmf function (trapezoidal signal)
Show older comments
Hello there :)
I have created the following trend:

This is the script I have used to for that:
%%init
clear; % clear workspace
close all; % close all figures
%%defintions
Fs = 2;
Ts = 1/Fs;
t =0:Ts:30;
%%create trapezoidal signal
% time vectors for trapezoidal signal
t_1 = t(1,1:((3/Ts)));
t_2 = t(1,((3/Ts)+1):((16/Ts)));
t_3 = t(1,((16/Ts+1)):((19/Ts)));
t_4 = t(1,((19/Ts+1)):end);
% trapmf(time_vector,[Start_of_trapez, First_edge_ second_edge, end_point])
trapez_1 = trapmf(t_1,[.5 1 2 2.5]);
trapez_2 = (trapmf(t_2,[3 3.5 4.5 5]))*-1; % inverse trapezoidal signal
trapez_3 = (trapmf(t_3,[16.5 17 18 18.5]))*-1;
trapez_4 = (trapmf(t_4,[19 19.5 20.5 21]));
% create complete signal containing trapez_1 to trapez_4
signal = [trapez_1 trapez_2 trapez_3 trapez_4];
%%plot signal
plot (t,signal);
xlabel('x');
ylabel('y');
title ('Nonlinearity');
grid on;
I would like to create a nonlinear trend for the marked areas on the picture above (I've only marked the first area for example). For this purpose, I would like to use a cubical function to create a nonlinear trend between the stationary areas. From my point of view, the way to do this is define a cubical function and add it to the areas, where a linear trend exists.
Is there any trick to do this with the created trapezoidal signal? I need to remain the rest of the signal as it is right now (that's what makes it tricky for me...)
I would be really thankful for any help :)
Thanks in advance.
Best regards, Niko
Accepted Answer
More Answers (0)
Categories
Find more on Descriptive Statistics 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!