How do I generate a Triangle function
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
How would I generate code for implementing the triangle function triangle(2Bt-n) for n = 1:20
so far:
t = 0:0.005:1;
g_t = 0;
g_a = sin(2*pi*t)+(0.5*cos(6*pi*t))+(0.25*cos(18*pi*t)); %given
B = 10;
for n = 1:20
h = 2*B*t-n;
g_t = g_t + (n/(2*B)).*g_a.*(1-abs(2*B*t-n));
end
figure(1);
hold on;
box on;
plot(t,g_t,'r');
plot(t,g_a,'b');
ylabel('amplitude g(t)');
xlabel('time t');
title('sync waveform reconstruction');
axis([0 1 -2 2]);
0 commentaires
Réponses (1)
Image Analyst
le 16 Fév 2016
How about using sawtooth(), or using triang() followed by repmat()?
3 commentaires
Image Analyst
le 16 Fév 2016
Attached is my demo. I've posted it several times before.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/182228/image.jpeg)
Voir également
Catégories
En savoir plus sur Waveform Generation dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!