How do I use fill to create continuous error bars?
古いコメントを表示
I was using the code to create continous error bars as referenced here, but could not get it to work for my dataset. Whenever I try and graph the data as a shaded area, I instead only get lines at each data point. I was able to get it to work for the values referenced in the example code, but cannot get it to work for my data set. How do I fix this?

n = 0;
for f = 500:25:1000
n = n+1;
freq(n) = f;
[Z_e_tot(n), Z_e_tot_err(n), R_e_tot(n), R_e_tot_err(n), X_e_tot(n), X_e_tot_err(n)] = imped_calc(f);
disp(f);
end;
figure()
hold on;
new_err = 1.*Z_e_tot_err;
fill([freq; flipud(freq)],[Z_e_tot-new_err;flipud(Z_e_tot+new_err)],[.9 .9 .9], 'linestyle', 'none');
line(freq, Z_e_tot);
2 件のコメント
Cris LaPierre
2020 年 10 月 13 日
It looks like we need your imped_calc function to be able to see what is happening. Can you attach it? Use the paperclip icon.
Justin Osborn
2020 年 10 月 13 日
採用された回答
その他の回答 (1 件)
Having your functino may not technically be necessary, but it sure makes it easier to ensure we are seeing what you see. In this case, your code is creating row vectors, but the solution you are using expects column vectors. Having your code create column vectors is all that is necessary to get your code to run. Instead of (n), use (n,1).
n = 0;
for f = 500:25:1000
n = n+1;
freq(n,1) = f;
[Z_e_tot(n,1), Z_e_tot_err(n,1), R_e_tot(n,1), R_e_tot_err(n,1), X_e_tot(n,1), X_e_tot_err(n,1)] = imped_calc(f);
end
new_err = 1.*Z_e_tot_err;
fill([freq; flipud(freq)],[Z_e_tot-new_err;flipud(Z_e_tot+new_err)],[.9 .9 .9], 'linestyle', 'none');
line(freq, Z_e_tot);
カテゴリ
ヘルプ センター および File Exchange で Mathematics についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

