checking script's output

2 次查看(过去 30 天)
milad babaei
milad babaei 2011-8-4
Hi all,
i've uesd those two code in a script to fit a polynomial on my data.the evauation output(command: polyval2(P,x,y))tells us,it's a good fit but when i made the equation with coefficients which produced by P = polyfitweighted2(x,y,z,9,w)i couldn't reach to that evaluated point( tested at specific point)which is produced by the coomand polyval2(P,x,y).i would like to ask somebody plz help me to find how could i get to a evaluated point through equation at a point???
link for two functions :
http://www.mathworks.com/matlabcentral/fileexchange/13719-2d-weighted-polynomial-fitting-and-evaluation
my script:
BoverH=1:8;
phi=0:10:30;
mydata = [ 1 1.02 1.11 1.21 1.3 1.4 1.59 1.78; ...
1 1.11 1.35 1.62 1.95 2.33 3.34 4.77; ...
1.01 1.39 2.12 3.29 5.17 8.29 22 61; ...
1.13 2.5 6.36 17.5 50 150 1400 14800];
h=log(mydata);
y=phi;
x=BoverH;
z=h;
w=ones(size(z));
P = polyfitweighted2(x,y,z,9,w);
[c, hh]=contour(x,y,z); clabel(c,hh), colorbar
title('data')
figure
[c, hh]=contour(x,y,polyval2(P,x,y)); clabel(c,hh), colorbar
title('equal weight')
  1 个评论
milad babaei
milad babaei 2011-8-4
According to the script and the function P = polyfitweighted2(x,y,z,9,w) and command polyval2(P,x,y),we able to make equation with coeff.which are made by function P.and evaluted the equation at a specific point like(X1,Y1).but my problem is :i couldn't get that equation to check and evaluate at the point which this command polyval2(P,x,y) gives me on output.i would like to ask you help me on making z equation .for example i reached to the equation after running the script and producing coefficients :
z=log(h): -0.0026-.0009(x^3)+0.0033(x^5)-0.0017(x^6)+0.003(x^7)-0.0004(x^6*y)+0.0004(x^4*y^3)-0.0002(x^3*y^4)+0.0001(x^2*y^5)
x=(B/H),y=phi..........at this (x=4 and y=0)point for evaluating fitted equation and checking the result of polyval2(P,x,y).it gives me z=log(h)=1.271....which h=e^1.271=3.56 but according to polyval2(P,x,y) output for this point gives us e^0.1936 =1.21??????
so my question is :is that equation which i have made with those coefficients correct???and why i couldnt get those evaluated number through the equation?also whats the W on a
> coefficients definition(wZ) on a script definition??

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Polynomials 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by