Transport delay generate to matlab function

조회 수: 2 (최근 30일)
Enes
Enes 2025년 2월 21일
댓글: Sam Chak 2025년 3월 10일
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
Sam Chak
Sam Chak 2025년 2월 21일

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

Enes
Enes 2025년 2월 21일
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.

댓글을 달려면 로그인하십시오.

답변 (1개)

Sam Chak
Sam Chak 2025년 2월 21일
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
Enes
Enes 2025년 2월 24일
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 2025년 3월 10일
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!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by