Borrar filtros
Borrar filtros

how to create a triangle wave in matlab?

92 visualizaciones (últimos 30 días)
Ningyi Liu
Ningyi Liu el 9 de Nov. de 2017
Respondida: Simon Leary el 11 de Abr. de 2022
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.

Respuestas (3)

Simon Leary
Simon Leary el 11 de Abr. de 2022
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 el 9 de Nov. de 2017

Eyad Samaan
Eyad Samaan el 19 de Mzo. de 2018
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);

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by