Le 23/07/2014 11:45, chloe.kykam a écrit :
k=6.63e-34*3e8/1.38e-23
x=[1;2;3;4;5;6;7;8;9;10]
y=[280;320;369.22772;391.25743;414.74257;439.75248;466.06931;493.60396;523.87129;530]
w=[0;0;1;1;1;1;1;1;1;0]

function y=yth(x,a)
     y=a(1)*exp(-k/x/a(2))
endfunction

a0=[1.0;1.0]

function e=myfun(a,x,y,w)
     e=w.*(yth(x,a)-y)
endfunction

[f,xopt,gopt]=leastsq(list(myfun,x,y,w),a0)

plot(x,y)
yy=yth(x, xopt)
plot(x,yy,'k--')
Hello.

As yth with x as a vector, you need a dot in the division :

function y=yth(x,a)
    y=a(1)*exp(-k./x/a(2))
endfunction


S.
_______________________________________________
users mailing list
[email protected]
http://lists.scilab.org/mailman/listinfo/users

Reply via email to