How do I put error bars on a best fit curve?

9 ビュー (過去 30 日間)
CAM
CAM 2016 年 3 月 28 日
コメント済み: Mike Garrity 2016 年 3 月 28 日
I have a series of data which I wanted to find the Gaussian of (I'll admit that it isn't a great fit, but that's the data I'm working with). The data came directly from a sensor measuring count rate at a specific bias voltage (so there is likely some noise).
What I'm doing in the program is calling the excel file (which contains the data from my sensor), then I am trying to put the error bars on the graph as well. When I run the code, I get the error bars separated from the actual graph itself! Can someone help me to get this code correct? It seems like it should be fairly simple, but I'm missing something. I'm attaching the excel file with the data points I pull!
clc
clear all
[v,T,vT]=xlsread('seventypointtwoZero.xlsx'); % calls the excel file
% 'xlsx' for excel 2007 and higher
%v: Double
%T and vT : cell
%use v containing numbers
t=v(:,1);
y=v(:,2);
f = fit(t,y,'gauss1')%Gaussian fit
yfit=feval(f,t)
plot(f,t,y)%plots the points and the Gaussian fit
hold on
errorbar(yfit, t)%plots the error bars
hold off
title('Bias of 70.2 Gaussian')
xlabel('Charge (ADC channels)') % x-axis label
ylabel('Counts') % y-axis label
Thanks!
  1 件のコメント
Mike Garrity
Mike Garrity 2016 年 3 月 28 日
I don't understand the intent of this line:
errorbar(yfit, t)%plots the error bars
The syntax for errorbar is some variant of this:
errorbar(X,Y,E) or errorbar(Y,E) plots Y with error bars [Y-E Y+E].
But isn't YFIT your Y coordinate, and T your X coordinate?
I would have expected something more like this:
errorbar(t,yfit,y-yfit)

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeErrorbars についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by