Repeating x-axis for rectangular signal

1 次查看(过去 30 天)
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.

采纳的回答

Star Strider
Star Strider 2019-1-24
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 个评论
youjarr
youjarr 2019-1-26
I´m not understanding the option 'MinSeparation'?! Separation between what because i can type in what i want it seems the the plots always looks the same?
And How can I use islocalmax to identify Positive nd negative flanks?
It seems that it can work much better than im doing now with diff.
But i dont understand it perfectly and I think the noise is maby to difficult for that function.
Star Strider
Star Strider 2019-1-26
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by