필터 지우기
필터 지우기

how to create a triangle wave in matlab?

조회 수: 92 (최근 30일)
Ningyi Liu
Ningyi Liu 2017년 11월 9일
답변: Simon Leary 2022년 4월 11일
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