Variable frequency triangular wave

조회 수: 5 (최근 30일)
HARISH
HARISH 2022년 10월 25일
답변: Yash 2023년 9월 22일
How to make triangular wave with variable frequency that varies over modulators period to obtain more samples in the area with the greatest slope. Carrier wave(triangular wave) should follow this law: ωi = ωc−kf · (sin(ωmt))2 - ωi =ωc, if sin(ωmt)=0 ωi =ωc−kf , if sin(ωmt)=±1.....wm=modulator freq. Wi=triangular wave Freq. K=modulation constant
  댓글 수: 6
KALYAN ACHARJYA
KALYAN ACHARJYA 2022년 10월 25일
편집: KALYAN ACHARJYA 2022년 10월 25일
Please share the code (use attachments icon), also share the expected outcomes/results.
HARISH
HARISH 2022년 10월 25일
fm=50; wm=2*pi*fm; t=linspace(0,0.02,500) if sin(wm*t)==0 wi=25*wm; elseif sin(wm*t)==1 wi=5*wm; elseif sin(wm*t)==-1 wi=5*wm; else wi=wm;
end

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

답변 (1개)

Yash
Yash 2023년 9월 22일
Hi Harish,
I understand that you are interested in generating a triangular wave with variable frequency.
The reason you are obtaining only one value for "wi" is because currently, "wi" is derived from a single value of "wm" based on the value of "sin(wmt)". However, since "t" is an array, "sin(wmt)" will also be an array. Consequently, comparing it to a single value will always yield false, resulting in "wi" being the same as "wm".
To address this, you can iterate over each value of "t" using a loop and calculate the frequency at each time step. By doing so, you will be able to obtain the desired variable frequency for the triangular wave.
It is important to note that the y-axis data for a triangular wave is always fixed, alternating between 0 and 1. Therefore, you only need to calculate the corresponding time values at which these transitions occur.
You can calculate the time values by utilizing the frequency at each time stamp as shown in the example below:
% Initialize variables here
% Array for storing timestamp values of 0 and 1
ts = zeros(1,length(t));
j=2;
for ti=t(1:end-1)
% Implement your logic to calculate "wi" here
% Once you have the value of "wi" calculate the next time stamp.
ts(j) = ts(j-1) + 2*pi/wi;
j=j+1;
end
% Creating an array of alternating 0 and 1.
yy = 1:length(ts);
yy = mod(yy,2);
plot(ts,yy)
I hope this explanation helps you in implementing the variable frequency triangular wave.
Best Regards
Yash

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by