How to plot an square ?
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi, do you know how to plot 4 signals as an square, I mean, every each line of a different colour creating an individual square or something like that.
I need to plot it with 4 analog inputs, on this case I'll use 4 pots with arduino... so.. anybody knows? Thank you.
4 comentarios
Kevin Holly
el 2 de Jun. de 2022
Do you mean a square wave?
plot(square(1:100))
ylim([-2,2])
Respuestas (1)
Kevin Holly
el 2 de Jun. de 2022
Editada: Kevin Holly
el 2 de Jun. de 2022
If it is 4 intersecting square waves, you could do this:
x = -10:0.001:10;
pi
plot(x,(pi/2)*square(x))
hold on
plot(x,-(pi/2)*square(x))
plot((pi/2)*square(x)+(pi/2),x-(pi/2))
plot(-(pi/2)*square(x)+(pi/2),x-(pi/2))
ylim([-6,6])
xlim([-4,7])
Edit: Made it scatter for clarity
figure
scatter(x,(pi/2)*square(x),'.')
hold on
scatter(x,-(pi/2)*square(x),'.')
scatter((pi/2)*square(x)+(pi/2),x-(pi/2),'.')
scatter(-(pi/2)*square(x)+(pi/2),x-(pi/2),'.')
ylim([-6,6])
xlim([-4,7])
3 comentarios
Kevin Holly
el 2 de Jun. de 2022
Editada: Kevin Holly
el 2 de Jun. de 2022
Perhaps, the potentiometers would be used to adjust the frequency of 4 different sine waves that are summed together create a square wave? Example.
Ver también
Categorías
Más información sobre Scatter Plots 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!


