MATLAB Answers

Error bars with zero standard deviation.

8 views (last 30 days)
Chirag Patil
Chirag Patil on 29 Jan 2020
Commented: Chirag Patil on 6 Feb 2020
Hello,
I have plotted a graph with x- and y-dataset. The standard deviation (in y-axis) has the following values and I intend to plot the error bars.
std_dev = [0 0.0295 0.0090 0.1239 0 0.5667 0.2855 0.0857]
Can I prevent the error-bars from appearing for dataset where std deviation is zero?
Thanks.

  0 Comments

Sign in to comment.

Answers (1)

KALYAN ACHARJYA
KALYAN ACHARJYA on 29 Jan 2020
std_dev = [0 0.0295 0.0090 0.1239 0 0.5667 0.2855 0.0857];
%Lets suppose
err=rand(1,8);
idx=find(std_dev~=0)
errorbar(std_dev(idx),err(idx));

  3 Comments

Chirag Patil
Chirag Patil on 29 Jan 2020
Thanks for your response. Maybe my question was not clear. Lets consider the following:
std_dev = [0.33 0.0295 0.0090 0.1239 0.434 0.5667 0.2855 0.0857];
err=rand(1,8); err(2) = 0;
errorbar(std_dev,err,'o','LineWidth',2);
In the above code, you can still see an error bar for the 2nd data set (which is equal to zero). I do not want this error bar, when error is zero, because it doesnt make any sense. At the same time, I want that second data set to be plotted and not removed.
KALYAN ACHARJYA
KALYAN ACHARJYA on 29 Jan 2020
std_dev = [0.33 0.0295 0.0090 0.1239 0.434 0.5667 0.2855 0.0857 ];
err=rand(1,8); err(2) = 0 ;
idx=find(err~=0);
errorbar(std_dev(idx),err(idx),'o','LineWidth',2 );
Chirag Patil
Chirag Patil on 6 Feb 2020
Hello,
In the above code, you can see that std_dev(2) is missing. Only 7 data has been plotted. How to get a similar plot with all the 8 data sets and no error-bar on the 2nd data?

Sign in to comment.

Sign in to answer this question.