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 Kommentare

Jan
Jan am 2 Jun. 2022
I do not understand what you want to achieve. "use 4 pots with arduino"? "plot 4 signals as an square"? A square is a square and you need 4 corners. How can 4 "signals" create a square?
Kenzitis KH
Kenzitis KH am 2 Jun. 2022
Actually it's the goddamn question that my classmates and I we're doing to. Even the professor doesn't know how to solve it either, lol.
Do you mean a square wave?
plot(square(1:100))
ylim([-2,2])
Kenzitis KH
Kenzitis KH am 2 Jun. 2022
We're talking an it seems that the sum of the 4 analog inputs by the pots, must draw a single square

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Kevin Holly
Kevin Holly am 2 Jun. 2022
Bearbeitet: Kevin Holly am 2 Jun. 2022

0 Stimmen

If it is 4 intersecting square waves, you could do this:
x = -10:0.001:10;
pi
ans = 3.1416
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 Kommentare

Kenzitis KH
Kenzitis KH am 2 Jun. 2022
Wow, that would be, NICE, but the sum of the 4 analog inputs by the pots, must draw a single square, that's what we're talking about... Idk how our teacher also doesn't know how to explain it or smthing, you know..
Kevin Holly
Kevin Holly am 2 Jun. 2022
Bearbeitet: Kevin Holly am 2 Jun. 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.
Kenzitis KH
Kenzitis KH am 2 Jun. 2022
Thanks 4 helping!!!
It supposed if you're summing the 4 pots, has to plot a square, plotting a square by using 4 pots.. something like that.

Melden Sie sich an, um zu kommentieren.

Gefragt:

am 2 Jun. 2022

Kommentiert:

am 2 Jun. 2022

Community Treasure Hunt

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

Start Hunting!

Translated by