Filter löschen
Filter löschen

display errorbar on each point in the curve matlab code

3 Ansichten (letzte 30 Tage)
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 Kommentare
Saurabh Patel
Saurabh Patel am 13 Mai 2023
% 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');
bassant tolba
bassant tolba am 14 Mai 2023
Thank you very much for your answer.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Saurabh Patel
Saurabh Patel am 13 Mai 2023
% 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');

Weitere Antworten (0)

Kategorien

Mehr zu Errorbars finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by