error analysis with errbar function
显示 更早的评论
I want to plo the data with different errorbar. I have plot the data using following code but my all errorbars of same lenght. I want erroerbars with the different lenght and auto generted. what do I need to change in my code? I am plotting the standard error .
thanks in advance!
pulsewidth_5v = 1×10
20.0000 10.0000 4.0000 2.0000 1.0000 0.4167 0.2000 0.0952 0.0645 0.0323
diameter_5v = 1×10
0.3122 0.2924 0.2624 0.2475 0.2057 0.1977 0.1797 0.1723 0.1673 0.1400
% 5v data
N = length(diameter_5v);
err = std(diameter_5v)/sqrt(N)*ones(size(diameter_5v));
errorbar(pulsewidth_5v,diameter_5v,err,"mo");
回答(1 个)
the cyclist
2021-4-20
0 个投票
This section of the documentation explains how to control error bar length in all directions.
6 个评论
Somnath Kale
2021-4-20
the cyclist
2021-4-20
I thought you meant that the problem was with the plotting. But I see now that the problem is with the calculation.
As you say, you are trying to use the standard error. Specifically, you seem to be trying to calculate the standard error of the mean. But the formula you are using would be appropriate only if you are taking 10 measurements of the same thing. Then, you would calculate
- the mean [one number]
- the error in the estimate of the mean [also one number]
But you are taking 10 measurement of different things -- 10 different pulse widths. You are not taking the mean of anything. Your formula does not apply in this situation.
I see no way to estimate the error, from these data.
Somnath Kale
2021-4-20
The errorbar function can clearly create a figure of that type. There are many examples in the documentation. Here is another simple one, based on your data:
% Your width and diameter data
pulsewidth_5v = [20.0000 10.0000 4.0000 2.0000 1.0000 0.4167 0.2000 0.0952 0.0645 0.0323];
diameter_5v = [0.3122 0.2924 0.2624 0.2475 0.2057 0.1977 0.1797 0.1723 0.1673 0.1400];
% Simulate some random errors
rng default
err = randn(10,1)/10;
% Plot it
errorbar(pulsewidth_5v,diameter_5v,err,"mo");
You see that the problem is not in the plotting function. The problem is how you are calculating the error. The error cannot be calculated "automatically". How could MATLAB know the error?
You must understand how to calculate the error in your problem. You cannot just blindly use the standard error formula.
Somnath Kale
2021-4-20
the cyclist
2021-4-20
Just because something is a common data analysis technique, does not make it right for your data. I strongly suspect it is not.
Can you explain your data a little bit more? For example is pulsewidth_5v an independent variable that you have control over, and diameter_5v is something you are measuring? In that case, perhaps you are looking for a model to fit a function to that relationship?
In that case your "error" would be the residual between the predicted diameter and the measure diameter.
类别
在 帮助中心 和 File Exchange 中查找有关 Errorbars 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
