Highlighting the middle third of my data and plotting it_should be easy

1 visualización (últimos 30 días)
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')

Respuestas (2)

Walter Roberson
Walter Roberson el 16 de Jun. de 2011
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.

Etienne O'Brien
Etienne O'Brien el 17 de Jun. de 2011
Thanks Walter,
The red area on my plot is now closer to the middle third of the whole plto but it is still not in the right position.
The problem more easily identified if I normalize my data again so that index_normDisp_is_Zero has a higher value (e.g. 600). Initially, I normalized a variable called theDisp by subtracting 0.1006 from all values. Most recently I've normalized by subtracting 0.5006 from all values - which is why the value of index_normDisp_is_Zero is now a larger number.

Community Treasure Hunt

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

Start Hunting!

Translated by