Highlighting the middle third of my data and plotting it_should be easy
2 次查看(过去 30 天)
显示 更早的评论
I want to identify a range of data (30-60%) and plot it. I can do the plotting ok but I seem unable to pull out the range I need. Instead of highlighting the middle third (approx) of the x values my code has highlighted under half.
My data is in variables named: normDisp - which I plot on x axis. Contains 8179 values from -0.1 to 6 approx. theLoad - which I plot on y axis. Contains 8179 values from -0.0026 to 1.2 approx.
Within these variables (and on the plot) I want to identify the sub-range of 30-60% within the larger range spanning between: index_normDisp_is_Zero (has value of 172) AND index_maxLoad (has a value of 1816)
plot(normDisp(index_normDisp_is_Zero:index_maxLoad+250),theLoad(index_normDisp_is_Zero:index_maxLoad+250))
hold on
plot(normDisp(index_maxLoad),theLoad(index_maxLoad),'rX')
hold on
rowsToPlot=round(0.3*(index_maxLoad-index_normDisp_is_Zero)):round(0.6*(index_maxLoad-index_normDisp_is_Zero))
plot(normDisp(rowsToPlot,1),theLoad(rowsToPlot,1),'rO')
0 个评论
回答(2 个)
Walter Roberson
2011-6-16
rowsToPlot = index_normDisp_is_Zero + (round(0.3*(index_maxLoad-index_normDisp_is_Zero)):round(0.6*(index_maxLoad-index_normDisp_is_Zero)));
You calculated 0.3 and 0.6 of the distance from the start of the part of interest to the end of the part of interest, but you need to offset that by the start of the part of interest. For example, if the span of the section of interest was 10, you calculated 3 and 6 as your indices instead of calculating 3 and 6 in from the beginning of the section of interest.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!