Borrar filtros
Borrar filtros

display errorbar on each point in the curve matlab code

3 visualizaciones (últimos 30 días)
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 comentarios
Saurabh Patel
Saurabh Patel el 13 de Mayo de 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 el 14 de Mayo de 2023
Thank you very much for your answer.

Iniciar sesión para comentar.

Respuesta aceptada

Saurabh Patel
Saurabh Patel el 13 de Mayo de 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');

Más respuestas (0)

Categorías

Más información sobre Errorbars en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by