Effacer les filtres
Effacer les filtres

Create a triangular wave/sawtooth function.

7 vues (au cours des 30 derniers jours)
Alejandro Urbina
Alejandro Urbina le 10 Avr 2016
Commenté : Chad Greene le 11 Avr 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 commentaires
Chad Greene
Chad Greene le 10 Avr 2016
Seems to create a sawtooth for me.
Alejandro Urbina
Alejandro Urbina le 11 Avr 2016
this is what matlab is telling me...

Connectez-vous pour commenter.

Réponses (1)

reen2015
reen2015 le 11 Avr 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
  1 commentaire
Chad Greene
Chad Greene le 11 Avr 2016
I think raina is correct.

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by