필터 지우기
필터 지우기

Create a triangular wave/sawtooth function.

조회 수: 7 (최근 30일)
Alejandro Urbina
Alejandro Urbina 2016년 4월 10일
댓글: Chad Greene 2016년 4월 11일
I have been trying to graph a triangular wave,sawtooth function on math lab r2015a i have been the example code from their website
T = 10*(1/50); Fs = 1000; dt = 1/Fs; t = 0:dt:T-dt; x = sawtooth(2*pi*50*t);
plot(t,x);
but it dose3nt run...
i tried to make my own code to graph a regular line mx+b and get the absolute value of the function to let it repeat over all the t values and make the same result and limit the max value to 1
t = linspace(-2,2,1e4); % time vector [s] x = zeros(size(t)); % this creates a vector of zeros the same size % as the vector t x(mod(abs(t),2) < 1 | mod(abs(t),2) > 0 ) = 1;
tmin = min(t); tmax = max(t); xmin = -0.2; xmax = 1.2; plot(t,x); axis([tmin tmax xmin xmax]);
this is just graphing a regular line all...
i know im doing some lame mistake and thats why the code is not running in either cases... ill appreciate any type of help to make this run... thank you
  댓글 수: 2
Chad Greene
Chad Greene 2016년 4월 10일
Seems to create a sawtooth for me.
Alejandro Urbina
Alejandro Urbina 2016년 4월 11일
this is what matlab is telling me...

댓글을 달려면 로그인하십시오.

답변 (1개)

reen2015
reen2015 2016년 4월 11일
I think its because you have saved the file with name sawtooth, which is mattlab function name.
try saving using different name.. such as mysaw.m
the code below that you posted creates sawtooth even if you paste in caommand window
T = 10*(1/50); Fs = 1000; dt = 1/Fs; t = 0:dt:T-dt; x = sawtooth(2*pi*50*t);
plot(t,x);
good luck
raina

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by