How can i calculate the difference between two points at various positions on a plot?
3 次查看(过去 30 天)
显示 更早的评论
Hello All, i am fairly new to the MATlab program and am tasked with evaluating some data for a school project. I have been able to successfully plot 3 curves that form a step response graph. What i have are 3 arrays containing thousands of values each.
- Torque, Actual Position & Desired Position
The Torque plot increases in steps of 100 up to 1600. What i need to do is whenever the data in the torque array changes by an absolute value of more than 99, set a flag and go forward 250 data points and analyze how close Actual Position and Desired Position are at those points. However i'm having trouble trying to understand what approach would be best. Any help is appreciated, thanks.
0 个评论
回答(3 个)
Tom
2013-6-17
You can use the UNIQUE function to find when the torque values change, (assuming they only stay the same or increase from one point to the next?)
[~,I] = unique(Torque,'first');
actPos(I+250) - desPos(I+250);
0 个评论
Barnabas
2013-6-17
2 个评论
Tom
2013-6-17
the ~ suppresses an output: I want the second output from UNIQUE, but I can't get the second without also requesting the first, so to ignore the first output ~ is used.
I is then the element number of the first of each of the different torque values. It doesn't look for a specific change in torque value: you said it increases by steps of 100, so this looks for the point at which each step occurs.
Try this as an example:
Torque = [0 0 0 0 100 100 100 200 200 200 200 200 200 300];
[~,I] = unique(Torque,'first');
I =
1 5 8 14
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!