Variable frequency triangular wave

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 Kommentare

KALYAN ACHARJYA
KALYAN ACHARJYA am 25 Okt. 2022
What you have tried so far?
HARISH
HARISH am 25 Okt. 2022
Bearbeitet: HARISH am 25 Okt. 2022
Wrote this law in editor and used variable wi in repeating sequence frequency..but i was getting only one value of wi... Any other method i can do?.. basically i want carrier wave frequency depending on slope of modulator
KALYAN ACHARJYA
KALYAN ACHARJYA am 25 Okt. 2022
Bearbeitet: KALYAN ACHARJYA am 25 Okt. 2022
Have you used array to store the wi data and plot accordingly, dont forget to hold on within loop to get all the plots.
HARISH
HARISH am 25 Okt. 2022
I tried by using linspace but still not working
KALYAN ACHARJYA
KALYAN ACHARJYA am 25 Okt. 2022
Bearbeitet: KALYAN ACHARJYA am 25 Okt. 2022
Please share the code (use attachments icon), also share the expected outcomes/results.
HARISH
HARISH am 25 Okt. 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

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Yash
Yash am 22 Sep. 2023

0 Stimmen

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

Produkte

Version

R2022a

Gefragt:

am 25 Okt. 2022

Beantwortet:

am 22 Sep. 2023

Community Treasure Hunt

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

Start Hunting!

Translated by