Solving system of eqution using vectors

Hi,
I have a problem with solving of equation, where unknown are vectors (coordinates of set of points: seznamX, seznamY, seznamZ) and my part of the program for solving it is:
syms r x y z
[l, m, n, Q] = solve(2*sqrt((seznamX-x).^2+(seznamY-y).^2+(seznamZ-z).^2)==r*ones(1,e),[x,y,z,r]);
It means I want to interpolate these points [seznamX,seznamY,seznamZ] with sphere and find its centre.
After running the program, it stops after the line [l, m, n, Q] , where a work with l. It returns me "Error in sym/subsasgn".
Where is the problem and how could I solve it?
Thank you for reply.

답변 (1개)

darova
darova 2020년 1월 14일

0 개 추천

You should create a system of equations. You need 4 points and 4 equations
syms x0 y0 z0 r0
eq1 = (x0-x(1))^2 + (y0-y(1))^2 + (z0-z(1))^2 == r0^2;
% ...

댓글 수: 5

Anezka Koterova
Anezka Koterova 2020년 1월 16일
But the problem is which 4 points, when there is for example 27 points, which the spehre can be fitted.
darova
darova 2020년 1월 16일
What about fit function? Maybe you should take half of data
123.png
Anezka Koterova
Anezka Koterova 2020년 1월 16일
Yes I tried to do that, which leads to Least square method and this leads to minimizing the distance (of the points from centre) from the radius.
And I don´t know, what you mean "take half of data"?
Something like that
ix = z < mean(z); % take a half
x1 = x(ix);
y1 = y(ix);
z1 = z(ix);
F = @(a,b,c,r,x,y) sqrt( r.^2 - (x-a).^2 - (y-b).^2 ) + c;
f = fit([x1 y1],z1,F);
Anezka Koterova
Anezka Koterova 2020년 1월 18일
I do not understand this script. what means the first, last and fifth line?

이 질문은 마감되었습니다.

질문:

2020년 1월 14일

마감:

2021년 8월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by