display errorbar on each point in the curve matlab code

3 次查看(过去 30 天)
I have data point of two curves in one graph as follows
x=[2,4,6,8,10];
y1=[58.87 168 366 670.48 715];
y2=[51 147 327 525 645.69 ] ;
I want to display "errorbar" on each point for each curve with legend in one graph.
Please can anyone help me ?
Thanks in advance.
  3 个评论
Saurabh Patel
Saurabh Patel 2023-5-13
% User Data Collection
x=[2,4,6,8,10];
y1=[58.87 168 366 670.48 715];
y2=[51 147 327 525 645.69 ];
% define the error for eact errorbar
err_y1=30*ones(size(y1));
err_y2=25*ones(size(y2));
% Two Y-axis on same Plot
yyaxis left
errorbar(x,y1,err_y1,'LineWidth',2)
ylabel('Data of Y1');
xlabel('X-axis');
yyaxis right
errorbar(x,y2,err_y2,'LineWidth',2)
ylabel('Data of Y2');
% Insert Legend
labels={'Data of Y1','Data of Y2'};
legend(labels,'Location','northwest','Orientation','vertical');

请先登录,再进行评论。

采纳的回答

Saurabh Patel
Saurabh Patel 2023-5-13
% User Data Collection
x=[2,4,6,8,10];
y1=[58.87 168 366 670.48 715];
y2=[51 147 327 525 645.69 ];
% define the error for eact errorbar
err_y1=30*ones(size(y1));
err_y2=25*ones(size(y2));
% Two Y-axis on same Plot
yyaxis left
errorbar(x,y1,err_y1,'LineWidth',2)
ylabel('Data of Y1');
xlabel('X-axis');
yyaxis right
errorbar(x,y2,err_y2,'LineWidth',2)
ylabel('Data of Y2');
% Insert Legend
labels={'Data of Y1','Data of Y2'};
legend(labels,'Location','northwest','Orientation','vertical');

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Errorbars 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by