error bar on the graph

16 ビュー (過去 30 日間)
ahmad albngali
ahmad albngali 2020 年 4 月 21 日
コメント済み: Star Strider 2020 年 6 月 22 日
hi
after i have plot between x y and z ( scatter3(x, y, z))
x=[2.6,5.2,14,23.3,28.3,2.6,5.2,14,23.3,28.3,2.6,5.2,14,23.3,28.3];
y=[3.5,6.9,17.7,29.1,35.2,3.5,6.8,17.5,28.7,34.8,3.4,6.6,16.9,27.6,33.5];
z=[450,450,450,450,450,350,350,350,350,350,250,250,250,250,250];
i want to make error bar for y in the same graph
and i have the standard deviation for y
which is ( 0.047140452, 0.047140452, 0.047140452, 0.124721913, 0.047140452, 0.047140452, 0.047140452, 0.047140452, 0.124721913, 0.124721913, 0.047140452, 0.047140452, 0.047140452, 0.124721913, 0.124721913)
so could you tell me what is the code for that

採用された回答

Star Strider
Star Strider 2020 年 4 月 21 日
The error bars are difficult to see, so I multiplied them by 10 here:
x=[2.6,5.2,14,23.3,28.3,2.6,5.2,14,23.3,28.3,2.6,5.2,14,23.3,28.3];
y=[3.5,6.9,17.7,29.1,35.2,3.5,6.8,17.5,28.7,34.8,3.4,6.6,16.9,27.6,33.5];
z=[450,450,450,450,450,350,350,350,350,350,250,250,250,250,250];
ysd = [0.047140452, 0.047140452, 0.047140452, 0.124721913, 0.047140452, 0.047140452, 0.047140452, 0.047140452, 0.124721913, 0.124721913, 0.047140452, 0.047140452, 0.047140452, 0.124721913, 0.124721913];
xr = reshape(x, [], 3);
yr = reshape(y, [], 3);
zr = reshape(z, [], 3);
ysdr = reshape(ysd, [], 3)*10;
figure
hold on
for k1 = 1:size(xr,2)
for k2 = 1:size(xr,1)
plot3((xr(k2,k1)*[1 1]), (yr(k2,k1)+ysdr(k2,k1)*[-1 1]), (yr(2,k1)*[1 1]), '-r')
plot3((xr(k2,k1)), (yr(k2,k1)), (yr(2,k1)), '.r')
end
end
hold off
view(-60,30)
grid on
xlabel('X')
ylabel('Y')
zlabel('Z')
% legend('Y\pm10\sigma')
Experiment to get the result you want.
  16 件のコメント
ahmad albngali
ahmad albngali 2020 年 6 月 22 日
hi i try to do it but it is confusing
could you please show me hoe i do it in my examble ( in my code )
Star Strider
Star Strider 2020 年 6 月 22 日
Add them to the plot3 calls:
plot3((xr(k2,k1)*[1 1]), (yr(k2,k1)+ysdr(k2,k1)*[-1 1]), (zr(2,k1)*[1 1]), '-r', 'LineWidth',1.5)
plot3((xr(k2,k1)), (yr(k2,k1)), (zr(2,k1)), '.r', 'MarkerSize',10)
so the complete code is now:
% x= CTDIv
x=[2.6,5.2,14,23.3,28.3,2.6,5.2,14,23.3,28.3,2.6,5.2,14,23.3,28.3 ];
% y= planar average equilibrium dose (DEq)
y=[3.5,6.9,17.7,29.1,35.2,3.5,6.8,17.5,28.7,34.8,3.4,6.6,16.9,27.6,33.5 ];
% z= scanning length
z=[450,450,450,450,450,350,350,350,350,350,250,250,250,250,250];
% ysd= DEq standard deviation
ysd = [0.047140452, 0.047140452, 0.047140452, 0.124721913, 0.047140452, 0.047140452, 0.047140452, 0.047140452, 0.124721913, 0.124721913, 0.047140452, 0.047140452, 0.047140452, 0.124721913, 0.124721913];
xr = reshape(x, [], 3);
yr = reshape(y, [], 3);
zr = reshape(z, [], 3);
ysdr = reshape(ysd, [], 3)*5;
%for visualisation
figure
hold on
for k1 = 1:size(xr,2)
for k2 = 1:size(xr,1)
plot3((xr(k2,k1)*[1 1]), (yr(k2,k1)+ysdr(k2,k1)*[-1 1]), (zr(2,k1)*[1 1]), '-r', 'LineWidth',1.5)
plot3((xr(k2,k1)), (yr(k2,k1)), (zr(2,k1)), '.r', 'MarkerSize',10)
end
end
hold off
view(-60,30)
grid on
Change the values to create the result you want.
.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by