how do i solve for the unknown variable

3 visualizzazioni (ultimi 30 giorni)
rafael gonzalez
rafael gonzalez il 28 Set 2012
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

Risposte (1)

Razvan
Razvan il 28 Set 2012
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.

Community Treasure Hunt

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

Start Hunting!

Translated by