Repeating x-axis for rectangular signal
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
youjarr
am 24 Jan. 2019
Kommentiert: Star Strider
am 26 Jan. 2019
Hey guys,
i have an rectangular signal i want to plot.
On the Y axis is the voltage from 0 to 3.3 V (24945x1 single) and on the X axis is the position of the motor (circle) from 0-360°. (24945x1 double)
I have both signals but like I exprected it when I do
plot(Angle, Voltage)
it is not working like i wish. How can i let the X axis repeat it self and not overlapping the other datapoints.
0 Kommentare
Akzeptierte Antwort
Star Strider
am 24 Jan. 2019
Try something like this:
Angle = reshape(([1; 1; 1]*(0:359))', 1, []); % Create Data;
Voltage = reshape(sind([1; 10; 20]*(0:359))', 1, []); % Create Data;
figure
plot(Angle, Voltage) % Original Plot
contAngle = unwrap(Angle*pi/180)*180/pi; % Use ‘unwrap’ To Recover Serial Vector
figure
plot(contAngle, Voltage) % ‘Unwrapped’ Plot
xt = get(gca, 'XTick');
xtn = min(xt) : 90 : max(xt);
set(gca, 'Xtick',xtn, 'XTickLabel',ceil(rem(xtn,360.1)))
xlim([min(contAngle) max(contAngle)])
8 Kommentare
Star Strider
am 26 Jan. 2019
From the documentation on islocalmax:
‘Minimum separation between local maxima, specified as the comma-separated pair consisting of 'MinSeparation' and a nonnegative scalar. ’
Another option is the ischange (link) function. That might be more applicalbe to what you want to do.
Please understand that without a representative sample of your data, I cannot specifically answer your questions. I can only suggest solutions, not knowing if they are appropriate.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!