필터 지우기
필터 지우기

how do i solve for the unknown variable

조회 수: 1 (최근 30일)
rafael gonzalez
rafael gonzalez 2012년 9월 28일
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

답변 (1개)

Razvan
Razvan 2012년 9월 28일
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