Variable frequency triangular wave
10 views (last 30 days)
Show older comments
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 Comments
KALYAN ACHARJYA
on 25 Oct 2022
Edited: KALYAN ACHARJYA
on 25 Oct 2022
Please share the code (use attachments icon), also share the expected outcomes/results.
Answers (1)
Yash
on 22 Sep 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
0 Comments
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!