- #1
eliassiguenza
- 24
- 0
Anyone Help Matlab! Please!?
I am pretty bad at using matlab, i have never used it before and i don't know what's wrong with my code, i would honestly appreciate if someone could give me a hand.
Script:
x=linspace(0,5,10)';
y=[2.75 4.83 5.05 6.80 8.83 8.64 11.03 13.20 13.08 15.68]';
sy=[0.5 0.6 0.7 0.8 0.9 0.9 1.0 1.1 1.1 1.2]';
[c,sc]=regress(x,y,sy,1);
plot(x,polyval(c,x),x,y,'o');
errbar(x,y,sy)
Function:
function sc = cerror_2(x,y,sy)
% This function calculates the errors in the fitted coefficients a and b for
% a straight line fitting problem.
A=(sum (x.^2) ./ (sy.^2));
B=(sum (1 ./ sy.^2));
C=(((sum (1./sy.^2) * ((sum (x.^2) ./ (sy.^2))) - (sum (x./sy.^2)))));
sa = (1./C.*A);
sb = (1./C.*B);
sy = [sb,sa];
end
Error
? Error using ==> regress
Too many input arguments.
Error in ==> Problem11_Executer at 4
[c,sc]=regress(x,y,sy,1);
I am pretty bad at using matlab, i have never used it before and i don't know what's wrong with my code, i would honestly appreciate if someone could give me a hand.
Script:
x=linspace(0,5,10)';
y=[2.75 4.83 5.05 6.80 8.83 8.64 11.03 13.20 13.08 15.68]';
sy=[0.5 0.6 0.7 0.8 0.9 0.9 1.0 1.1 1.1 1.2]';
[c,sc]=regress(x,y,sy,1);
plot(x,polyval(c,x),x,y,'o');
errbar(x,y,sy)
Function:
function sc = cerror_2(x,y,sy)
% This function calculates the errors in the fitted coefficients a and b for
% a straight line fitting problem.
A=(sum (x.^2) ./ (sy.^2));
B=(sum (1 ./ sy.^2));
C=(((sum (1./sy.^2) * ((sum (x.^2) ./ (sy.^2))) - (sum (x./sy.^2)))));
sa = (1./C.*A);
sb = (1./C.*B);
sy = [sb,sa];
end
Error
? Error using ==> regress
Too many input arguments.
Error in ==> Problem11_Executer at 4
[c,sc]=regress(x,y,sy,1);