What features should I use to plot these charts?

 Accepted Answer

Hello Dani,
If you have the Signal Processing Toolbox, you can use sawtooth with the "xmax" argument to make the triangle wave, and square to make the square wave.
Once you've generated the signals, you can use a simple plot to display the wave, and axis to set the view range to your desired window.
-Cam

3 Comments

Hello Cam,
Thanks a lot for your answer .I've been doing something so far, but I don`t know how good it is. I took two equal vectors and represented them for the first graph, and for the second I proceeded as follows:
1st Graph :
t=[0 1 2 3 4 5 6 7 8 9 10];
x=[1 0 1 0 1 0 1 0 1 0 1];
plot(t,x,'LineWidth',2);
axis([0 10 -3 3]);
title('Graficul functiei u(t)')
ylabel('Amplitudine');
xlabel('Timp(s)')
2nd Graph
t=(0:0.001:10)
x=square(pi*t);
plot(t,x);
axis([0 10 0 2]);
title('Graficul functiei v(t)')
ylabel('Amplitudine');
xlabel('Timp(s)')
Yep, that seems to work. If you wanted to use sawtooth using this example as a guide, this is how you could do it for the first graph:
T = 5*2;
Fs = 100;
dt = 1/Fs;
t = -5:dt:5-dt;
x = sawtooth(2*pi*0.5*t, 0.5);
plot(t, x)
ylim([-4 4])
But your way is probably more readable. The original image did show from -5 to 5 though, not 0 to 10. Not sure how much that matters to you though.
I get it! Will also think about your version. Thank you for your patience !

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!