how do i solve for the unknown variable

I have 3 axis x y and z. I wish to find Z such that the sum of the squares would be equal to 1.
the data is stored in a vector with 3 columns. I want to substitute the last one with an unknown such that the sum of the squares of x y and z would equal to 1.
syms zz
for i=1:90
g(i) = sqrt (gx1(i,1) * gx1(i,1) + gy1(i,1) * gy1(i,1) + zz * zz) - 1
roots(i) = solve(g(i),zz);
end
I would greatly appreciate the help. thanks Rafael

Answers (1)

If you have the vectors x and y
e.g.
x = 0.5 * rand(10, 1);
y = 0.5 * rand(10, 1);
Then the z is simply
z = sqrt(1 - x.^2 - y.^2);
plus or minus that, depending if you want the positive or the negative root.

Asked:

on 28 Sep 2012

Community Treasure Hunt

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

Start Hunting!