hi,
I use the function solve to determine a variable as follows:
x = solve (cos (x) * sin (y) * cos (z) + sin (Z) = 1 ',' x ')
then I evaluated x in terms of y and z, when I replace x by the value finding the equation is not = 1!!
how can i resolve it?

답변 (1개)

Walter Roberson
Walter Roberson 2015년 5월 13일

0 개 추천

Are x and y and z symbolic at the time you call solve? Or are y and z numeric?
If they are symbolic and you later substitute in numeric y and z to the solve() response get a numeric x, and then substitute the numeric x, y, and z into the cos (x) * sin (y) * cos (z) + sin (Z) formula, then you could get something other than 1 due to round-off error.
Also, if your y and z are square matrices of numeric values, then cos (x) * sin (y) * cos (z) would succeed but what not be what you want: you would need to evaluate
cos(x) .* sin(y) .* cos(z)
Notice the ".*" instead of "*" if you are working with vectors or matrices.

댓글 수: 4

studentU
studentU 2015년 5월 13일
편집: studentU 2015년 5월 22일
thank's for your repply,
the x and y are the symbolic when i call solve,
you're talking about ".*" in the verification? or at the eval function?
Walter Roberson
Walter Roberson 2015년 5월 13일
When you do the numeric verification, if you are testing with vectors of values, then you will need to use .* vectorization when you write the formulas. Or you could use matlabFunction() on the symbolic expression as that will automatically vectorize.
If you are doing symbolic verification instead of numeric, and you do not get 1, then you might need to simplify() the result.
studentU
studentU 2015년 5월 13일
편집: studentU 2015년 5월 13일
I used simplify () but the result is always diferrent 1,
However, how to limit the interval of solution; for
x = solve ('cos (x) * sin (y) * cos (z) + sin (Z) = 1 ',' x ')
i want x beteween 0° and 90° for exmple,
thank's lot,
Torsten
Torsten 2015년 5월 22일
I'd be interested what you get for x after applying "solve".
Best wishes
Torsten.

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

카테고리

태그

질문:

2015년 5월 13일

댓글:

2015년 5월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by