Finding the x value for a given y value on a plot
11 次查看(过去 30 天)
显示 更早的评论
Hi,
I would like to get help with finding the corresponding x values for a given y value.
With reference to the plot that I have, I managed to find the peak values (as denoted by the blue arrows) for each curve of the graph. Now I would like to find the x values (time) for 30% and 90% of the peak y value (torque) that I found.
If possible, I would also like to know how I can find the highest slope/gradient of each curve on the graph between the times at 30% and 90% of the peak torque value.
x = TimeSeconds;
y = TorqueNewtonMeters;
graph = plot (x,y);
pks = findpeaks(y,'MinPeakProminence', 100);
thirtypercentpks = 0.3*pks;
ninetypercentpks = 0.9*pks;
Thank you!
0 个评论
回答(1 个)
Adam Danz
2020-4-14
Check out the 2nd output to findpeaks, it gives you the x-values.
[pks,locs] = findpeaks(data) <--link
4 个评论
Adam Danz
2020-4-15
编辑:Adam Danz
2020-4-17
1) You can use vq = interp1(x,v,xq) to resample the (x,y) data to a finer resolution. The finer the resolution, the smaller the error will be between the selected y-value and the actual y-value that represents the x% mark.
2) Compute the height of each peak. Then compute 30% and 90% of the peak value. Let's say that y value at the peak is p, the y value at the 30% mark would be p*.3.
3) Locate the closest values to p*.3 and p*.9 y-values just before and just after the peak. You may want to segment the curves from the closest near-0 y-value to the peak. There are lots of ways to approach this step so once you get here, try some approaches and let us know if you get stuck & show us what you've got.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!