MATLAB Answers

M.A.
0

Curve fitting with coefficient as function of x

M.A.
さんによって質問されました 2017 年 6 月 7 日
最新アクティビティ M.A.
さんによって コメントされました 2017 年 6 月 16 日
New user of 'cftool box' here. I am trying to fit an experimental dataset to extract few parameters. One of the parameter is also function of x. How to retrieve this parameter? Because most of the cftool examples show the fitting with real value coefficients. I appreciate any response. Thanks.

  2 件のコメント

John D'Errico
2017 年 6 月 7 日
If a parameter is a function of x, then it is not a parameter that you can freely estimate.
Perhaps you need to show the model that you want to estimate. Otherwise it is impossible to answer your question.
M.A.
2017 年 6 月 8 日
Thanks John for your response. I am not sure whats the best way to explain, so I will try with the code I am working with.
function y=ARfit(x,n2,daSi,theta_in)
extinct_rat=17.00885;
pol_extinction_ratio=10.^(extinct_rat/10); p_power_frac=pol_extinction_ratio./(pol_extinction_ratio+1); s_power_frac=1./(pol_extinction_ratio+1);
n1=1;
n4=3.48066;
n3=1.464;
theta_t_1=(180/pi)*asin(n1*sin(theta_in*pi/180)/n2);
theta_t_2=(180/pi)*asin(n2*sin(theta_t_1*pi/180)/n3);
theta_t_3=(180/pi)*asin(n3*sin(theta_t_2*pi/180)/n4);
d2=117.72;
i=theta_in; o=theta_t_1; p=theta_t_2; q=theta_t_3;
R1s=(n1*cos(pi*i/180)-n2*cos(pi*o/180))/(n1*cos(pi*i/180)+n2*cos(pi*o/180)); R1p=(n2*cos(i*pi/180)-n1*cos(o*pi/180))/(n2*cos(i*pi/180)+n1*cos(o*pi/180)); % p-pol R2s=(n2*cos(pi*o/180)-n3*cos(pi*p/180))/(n2*cos(pi*o/180)+n3*cos(pi*p/180)); R2p=(n3*cos(o*pi/180)-n2*cos(p*pi/180))/(n3*cos(o*pi/180)+n2*cos(p*pi/180)); % p-pol R3s=(n3*cos(pi*p/180)-n4*cos(pi*q/180))/(n3*cos(pi*p/180)+n4*cos(pi*q/180)); R3p=(n4*cos(p*pi/180)-n3*cos(q*pi/180))/(n4*cos(p*pi/180)+n3*cos(q*pi/180)); % p-pol
k1l1=(2*pi./x)*n2*daSi*cos(o*pi/180); y1=complex(cos(2*k1l1)-1i*sin(2*k1l1)); k2l2=(2*pi./x)*n3*d2*cos(p*pi/180); x1=complex(cos(2*k2l2)-1i*sin(2*k2l2)); a1s=R1s+R2s.*y1+R1s*R2s*R3s.*x1+R3s.*x1.*y1; b1s=1+R1s*R2s.*y1+R2s*R3s.*x1+R1s*R3s.*x1.*y1; Rx1s=abs((a1s./b1s).^2)*100; a1p=R1p+R2p.*y1+R1p*R2p*R3p.*x1+R3p.*x1.*y1; b1p=1+R1p*R2p.*y1+R2p*R3p.*x1+R1p*R3p.*x1.*y1; Rx1p=abs((a1p./b1p).^2)*100;
R1_dbm=10*log10(s_power_frac.*Rx1s/100+p_power_frac.*Rx1p/100);
y=R1_dbm;
*As you can see, I am using an 'user defined function' to fit the data to determine n2,daSi,theta_in. But since the n2 is function x, I would like determine that with respect each x data point. I think it is appropriate to say that the input n4 and n3 are also x dependent, for simplicity I am considering average value. So how I can accommodate these inputs. I tried an extra user defined function inside this code to extract n3(=f(x)), but it doesn't work.
Is it clear? Thanks in advance!*

サインイン to comment.

1 件の回答

回答者: Shruti Shivaramakrishnan 2017 年 6 月 16 日

I might have missed it, however, how is n2 defined or assigned? Also you mentioned that n3 and n4 values are being averaged out. How are they defined? or what are they being averaged from i.e. a range dependent on x based on a function?

  1 件のコメント

M.A.
2017 年 6 月 16 日
Hi Shruti, What I mean by averaging n3 and n4 is that, they are x dependent values, but I consider an average of them. Assuming this, when I fit the y vs x I get n2 which is also averaged over x. But I am trying to improve fitting. So I want include inputs that are x dependent, therefore I would like determine parameter that are x dependent. Does it make sense?

サインイン to comment.



Translated by