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.

 採用された回答

the cyclist
the cyclist 2022 年 3 月 8 日

0 投票

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 件のコメント

Nicholas Modar
Nicholas Modar 2022 年 3 月 8 日
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)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeErrorbars についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by