Borrar filtros
Borrar filtros

Create a triangular wave/sawtooth function.

7 visualizaciones (últimos 30 días)
Alejandro Urbina
Alejandro Urbina el 10 de Abr. de 2016
Comentada: Chad Greene el 11 de Abr. de 2016
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 comentarios
Chad Greene
Chad Greene el 10 de Abr. de 2016
Seems to create a sawtooth for me.
Alejandro Urbina
Alejandro Urbina el 11 de Abr. de 2016
this is what matlab is telling me...

Iniciar sesión para comentar.

Respuestas (1)

reen2015
reen2015 el 11 de Abr. de 2016
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

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by