Hello,
I have a 1x1501 variable. I wish to plot the variable and include error bars. I have a set of error values that are also 1x1501 in size.
I wish to plot 7 error values and hide the rest. The "errorbar" function will not let me choose what error values I would like to plot and requires that the length be the same.

 Akzeptierte Antwort

the cyclist
the cyclist am 8 Mär. 2022

0 Stimmen

Imagine a smaller example, where you have a 1x5 variable to plot, and 1x5 errors. Suppose the vectors are
x = 1:5;
vec = [2 3 5 7 9];
errVec = [0.2 0.3 1 3 2];
and you only want to plot the first two. You can create a second vector, of the same length, but with NaN values, and use it for plotting:
errVecNaN = [0.2 0.3 nan nan nan];
errorbar(x,vec,errVecNaN)
The best way to create the vector with NaN values will depend on exactly which ones you want to replace.

1 Kommentar

Nicholas Modar
Nicholas Modar am 8 Mär. 2022
Thanks so much. Ended up doing pretty much the same thing.
errorNANmatrix = NaN(1,1501);
errorNANmatrix(1,1) = dist0km;
errorNANmatrix(1,251) = dist25km;
errorNANmatrix(1,501) = dist50km;
errorNANmatrix(1,751) = dist75km;
errorNANmatrix(1,1001) = dist100km;
errorNANmatrix(1,1251) = dist125km;
errorNANmatrix(1,1501) = dist150km;
errorbar(meanRtemp_djf, errorNANmatrix)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by