How to use the nonlinear least square fitting to fit a transfer function?How to improve the fitting accuracy
I have a dataset Y representing the real part Y(:,1) and the imaginary part (Y:,2) of a function against the frequency fq. I want to find the coefficient of the transfer function to have the a good fit with the dataset. The transfer function is given assumed to have a fifth order, (so there are totally 10 unknowns) T(p,q,s)=p(5)*s^4+p(4)*s^3+p(3)*s^2+p(2)*s+p(1))/(s^5+q(5)*s^4+q(4)*s^3+q(3)*s^2+q(2)*s+q(1));
The code is given in the attached, I split the objective function as the imaginary and real part respectively, the objective function is (real(T)-Y(:,1))^2+(imag(T)-Y(:,2)) over all the selected points in the Y-fq curve.
The blue circle is the fitted result from the NLSQ, but they are slightly away from the original data. My question is how to improve the code to improve the fitting result.
In the attached files,"nonlsqfitting.mat" is the Y and fq data; NLSFmat is the runing code; OBJrealimag.m is the objective function, where Yout(:,1) is the real part of T and Yout(:,2) is the imaginary part of T.I have a dataset Y representing the real part Y(:,1) and the imaginary part (Y:,2) of a function against the frequency fq. I want to find the coefficient of the transfer function to have the a good fit with the dataset. The transfer function is given assumed to have a fifth order, (so there are totally 10 unknowns) T(p,q,s)=p(5)*s^4+p(4)*s^3+p(3)*s^2+p(2)*s+p(1))/(s^5+q(5)*s^4+q(4)*s^3+q(3)*s^2+q(2)*s+q(1));
The code is given in the attached, I split the objective function as the imaginary and real part respectively, the objective function is (real(T)-Y(:,1))^2+(imag(T)-Y(:,2)) over all the selected points in the Y-fq curve.
The blue circle is the fitted result from the NLSQ, but they are slightly away from the original data. My question is how to improve the code to improve the fitting result.
In the attached files,"nonlsqfitting.mat" is the Y and fq data; NLSFmat is the runing code; OBJrealimag.m is the objective function, where Yout(:,1) is the real part of T and Yout(:,2) is the imaginary part of T. I have a dataset Y representing the real part Y(:,1) and the imaginary part (Y:,2) of a function against the frequency fq. I want to find the coefficient of the transfer function to have the a good fit with the dataset. The transfer function is given assumed to have a fifth order, (so there are totally 10 unknowns) T(p,q,s)=p(5)*s^4+p(4)*s^3+p(3)*s^2+p(2)*s+p(1))/(s^5+q(5)*s^4+q(4)*s^3+q(3)*s^2+q(2)*s+q(1));
The code is given in the attached, I split the objective function as the imaginary and real part respectively, the objective function is (real(T)-Y(:,1))^2+(imag(T)-Y(:,2)) over all the selected points in the Y-fq curve.
The blue circle is the fitted result from the NLSQ, but they are slightly away from the original data. My question is how to improve the code to improve the fitting result.
In the attached files,"nonlsqfitting.mat" is the Y and fq data; NLSFmat is the runing code; OBJrealimag.m is the objective function, where Yout(:,1) is the real part of T and Yout(:,2) is the imaginary part of T. nonlinear least square fitting transfer function MATLAB Answers — New Questions









