how to create a triangle wave in matlab?

90 次查看(过去 30 天)
How do I plot "a triangle wave with frequency of 1 kHz that's 3 V peak-to-peak with a minimum voltage of 0 volts" in matlab?
I attached the excel graphs that is my simulation plot and measured plot, the theoretical graph created from Matlab should look similar to it.

回答(3 个)

Simon Leary
Simon Leary 2022-4-11
function output = triangle(t, period, amplitude)
% sawtooth uses amplitude of time array to get period
% multiply t by 2pi, divide by your desired period
t1 = t*2*pi/period;
% 0.5 is the fraction of the period where sawtooth peaks, I think
output = sawtooth(t1, 0.5);
% default range of sawtooth is -1 to 1, add 1 to get 0 to 2
% then divide by 1 to get 0 to 1
output = (output + 1)/2;
output = output*amplitude;
end

Image Analyst
Image Analyst 2017-11-9

Eyad Samaan
Eyad Samaan 2018-3-19
V=10; f0=1; w0=2*pi*f0; T=1/f0; T1=T/2; T2=1-T/2; f1=1/T1; f2=1/T2; d=1/2; dT=T/512; t1=0:dT: d* T-dT ; t2=d*T:dT: T-dT; t=[t1 t2]; figure; v1= V * triangle ( 2* pi* f1*t1 ); v2=-V*triangle (2*pi*f2*t2);

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by