Variable frequency triangular wave

7 visualizzazioni (ultimi 30 giorni)
HARISH
HARISH il 25 Ott 2022
Risposto: Yash il 22 Set 2023
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 Commenti
KALYAN ACHARJYA
KALYAN ACHARJYA il 25 Ott 2022
Modificato: KALYAN ACHARJYA il 25 Ott 2022
Please share the code (use attachments icon), also share the expected outcomes/results.
HARISH
HARISH il 25 Ott 2022
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

Accedi per commentare.

Risposte (1)

Yash
Yash il 22 Set 2023
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

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by