Transport delay generate to matlab function

6 views (last 30 days)
Enes
Enes on 21 Feb 2025
Commented: Sam Chak on 10 Mar 2025
Hello
I wanted to draw the same triangular waves with phase shifting using transport delay and I succeeded. But I want to do this using matlab function. How can I do it?
  2 Comments
Sam Chak
Sam Chak on 21 Feb 2025

Can you provide the triangular wave function? Once you have that, we can determine the translational shift on the x-axis.

Enes
Enes on 21 Feb 2025
I understand, it makes sense. The equation is like this 0≤x<12.5μs: y=80000x
12.5μs≤x<25μs: y=−80000x+2 like this. This is for my waveform. The second one will start after this one ends and will have the same form.

Sign in to comment.

Answers (1)

Sam Chak
Sam Chak on 21 Feb 2025
I applied the modulo operation to the triangular membership function from the Fuzzy Logic Toolbox to create the equilateral triangular wave. You can adjust the base length (period) and the phases to suit your application. Personally, I prefer the trimf() function, but you may also use the sawtooth() function. If you would like to create your own version of the triangular function, please replace the trimf() function accordingly. The MATLAB Function block should support the mod(), trimf(), and sawtooth() functions.
t = linspace(0, 4*sqrt(3), 7001);
p = 2/sqrt(3); % period (base length of Equilateral triangle)
z1 = mod(t - 0*p/4, p); % modulo operation
z2 = mod(t - 1*p/4, p);
z3 = mod(t - 2*p/4, p);
z4 = mod(t - 3*p/4, p);
y1 = trimf(z1, [0*p 1*p/2 1*p]); % blue
y2 = trimf(z2, [0*p 1*p/2 1*p]); % red
y3 = trimf(z3, [0*p 1*p/2 1*p]); % orange
y4 = trimf(z4, [0*p 1*p/2 1*p]); % purple
plot(t, [y1; y2; y3; y4]), grid on, axis equal
xlabel('Time'), ylabel('Amplitude')
  2 Comments
Enes
Enes on 24 Feb 2025
thank you so much sir. i added 8 signal totally my code is below: by the way this code in simulink matlab function block
function [y1, y2, y3, y4, y5, y6, y7, y8] = phaseShiftedSignals(t, p)
% % %Inputs:
% % % t: Time vector
% % % p: Period
% % %Phase-shifted signals
z1 = mod(t - 0*p/8, p); % No phase shift
z2 = mod(t - 1*p/8, p); % Phase shift: p/8
z3 = mod(t - 2*p/8, p); % Phase shift: 2p/8
z4 = mod(t - 3*p/8, p); % Phase shift: 3p/8
z5 = mod(t - 4*p/8, p); % Phase shift: 4p/8
z6 = mod(t - 5*p/8, p); % Phase shift: 5p/8
z7 = mod(t - 6*p/8, p); % Phase shift: 6p/8
z8 = mod(t - 7*p/8, p); % Phase shift: 7p/8
% % %Triangular membership functions
y1 = trimf(z1, [0, p/2, p]);
y2 = trimf(z2, [0, p/2, p]);
y3 = trimf(z3, [0, p/2, p]);
y4 = trimf(z4, [0, p/2, p]);
y5 = trimf(z5, [0, p/2, p]);
y6 = trimf(z6, [0, p/2, p]);
y7 = trimf(z7, [0, p/2, p]);
y8 = trimf(z8, [0, p/2, p]);
end
Sam Chak
Sam Chak on 10 Mar 2025
If you find my mathematical formula helpful for creating the equilateral triangular waves, please consider clicking 'Accept' ✔ on the answer and voting 👍 for it. Your support is greatly appreciated!

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!