Solving over determined algebraic system in MATALB

Hi I am trying to solve over determined system which is algebraic. Below is the over determined system explained.
u=linspace(0,2,30)
for i=1:30
v(i,:)=2+tan(u(i)/(1+u(i).^2))
end
f=((a-b+c+d)*(a-b-c+d)*(u^2)*(v^2))+((a+b-c+d)*(a+b+c+d)*(u^2))+((a+b-c-d)*(a+b-c-d)*(a+b+c-d)*(v^2))-(8*a*b*u*v)+((a-b+c-d)*(a-b-c-d))
there are 30 values of u and 30 values of v but how I will be able to find a,b and c if we put d as 1

댓글 수: 5

Torsten
Torsten 2018년 4월 13일
편집: Torsten 2018년 4월 13일
You want to determine a, b and c such that f(i,j)=0 approximately for all given pairs (u(i),v(j)) ?
Abdullah Nasir
Abdullah Nasir 2018년 4월 13일
편집: Abdullah Nasir 2018년 4월 14일
Yes exactly I need to determine a, b and c such that f(i,j)=0 approximately for all given pairs (u(i),v(j))
Thank you
Do you have the curve fitting toolbox?
Yes I have the curve fitting toolbox but I have never used it
Thank you
What are your inputs? Do you have one known f value for each u value?

댓글을 달려면 로그인하십시오.

 채택된 답변

Walter Roberson
Walter Roberson 2018년 4월 14일
%it is important that the independent variable, u, be last for curvefit purposes
fun = @(a,b,c,u) u.^2*(a + b + c + 1).*(a + b - c + 1) - (a - b + c - 1).*(b - a + c + 1) + (tan(u./(u.^2 + 1)) + 2).^2.*(a + b + c - 1).*(a + b - c - 1).^2 - 8.*a.*b.*u.*(tan(u./(u.^2 + 1)) + 2) + u.^2.*(tan(u./(u.^2 + 1)) + 2).^2.*(a - b - c + 1).*(a - b + c + 1);
fitobj = fittype(fun, 'independent', 'u');
u = linspace(0,2,30);
results = fit(u(:), known_f(:), fitobj)
I did not have any known f values to work with, so I used rand(). The coefficients I got back passed through 0, which typically indicates that you cannot trust the results at all. But you could potentially get better results with your actual known f values.

댓글 수: 5

Hi Sorry I need to determine a, b and c such that f(i,j)=0 approximately for all given pairs (u(i),v(j)). (f) it the function.
Thank you
Ah, in that case use known_f = zeros(size(u));
results =
General model:
results(u) = u.^2*(a+b+c+1).*(a+b-c+1)-(a-b+c-1).*(b-a+c+1)+(tan(u./(u.^2+
1))+2).^2.*(a+b+c-1).*(a+b-c-1).^2-8.*a.*b.*u.*(tan(u./(u.^2+
1))+2)+u.^2.*(tan(u./(u.^2+1))+2).^2.*(a-b-c+1).*(a-
b+c+1)
Coefficients (with 95% confidence bounds):
a = -0.3037 (-0.3283, -0.2791)
b = 0.4132 (0.4004, 0.4261)
c = 0.6249 (0.6205, 0.6294)
Your v values are not givens: they are calculated from your u values in your loop at the beginning.
By the way is there any other way to solve this type of problem without using the curve fitting tools. This problem states as non-linear least square problem.
Thank you
Curvefit uses nonlinear least squares when it is handed a function handle, as is the case we constructed here.
Note, though, that fit() (as above) expects the function to return a predicted value, and fit() itself subtracts off the actual value and constructs sum of squares of those. But lsqnonlin expects instead that the function already have subtracted off the actual value (but expects a vector output and it will calculate the sum of squares of those.)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Interpolation of 2-D Selections in 3-D Grids에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by