필터 지우기
필터 지우기

Need Help with a Simple Symbolic Equation Solve in Matlab 2015a

조회 수: 1 (최근 30일)
S H
S H 2015년 7월 24일
댓글: S H 2019년 1월 28일
I am trying the following code in Matlab 2015a. It cannot solve it. Correct solution should be simply k. Could you tell me what is wrong?
syms Z k
assume(Z,'real')
assume(k,'real')
[Z]=solve(abs(k/(k+1i*Z))==1/sqrt(2));
Z=????
  댓글 수: 2
Roger Stafford
Roger Stafford 2015년 7월 24일
Without your assumptions that k and Z are real, the solution for any given k would be Z = w*k where w = x+1i*y is any point on the circle in the complex plane:
x^2 + (y-1)^2 = 2
In other words there would be an infinite continuum of possible solutions and 'solve' could not give you an answer.
Given that k and Z must be real, the solution is thereby restricted to the two points, Z = k and Z = -k, where the circle crosses the real line, so that 'solve' could and should have given you that answer. I suspect that the combination of the given assumptions together with the 'abs' operator confused Mathworks' 'solve' to the point where it was unable to give this simple answer.
S H
S H 2015년 7월 24일
Even if I try the following code, still Matlab answer does not make any sense:
clear all
syms Z k
[sol]=solve(abs(k/(k+1i*Z))==1/sqrt(2),Z);
.
.
.
and the answer will be k*1i + 2^(1/2)*abs(k)*1i which cannot be interpreted in anyhow as the correct answer of k.

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

답변 (4개)

Torsten
Torsten 2015년 7월 24일
Maybe
[Z]=solve(abs(k/(k+1i*Z))==1/sqrt(2),Z);
?
Best wishes
Torsten.

S H
S H 2015년 7월 24일
Still does not work or better said, Matlab cannot solve this simple equation.

Sean de Wolski
Sean de Wolski 2015년 7월 24일
One equation with two unknowns. What do you expect?
Torsten's suggestion gives you the result for Z:
ZZ = solve(abs(k/(k+1i*Z))==1/sqrt(2),Z);
ZZ = k*1i - 2^(1/2)*exp(z*2i)*abs(k)*1i
But it will of course include k because you have two unknowns.

S H
S H 2015년 7월 24일
편집: S H 2015년 7월 24일
It is not one equation with two unknowns as laid out clearly by Matlab symbolic documentation. The solve function should be able to find one symbolic variable in terms of other symbolic variables. In this case, Matlab provides a ridiculous answer of Z = k*1i - 2^(1/2)*exp(z*2i)*abs(k)*1i. But the correct answer must be simply Z=k. What needs to be answered is how Matlab cannot solve such a simple equation while Symbolic documentation shows the solve function is capable of finding all complex trigonometric functions in terms of symbolic variables. If there is no way that Matlab 2015a and older versions can find Z=k as the answer, then I consider this as a bug or premature Matlab symbolic tool.
  댓글 수: 2
Walter Roberson
Walter Roberson 2015년 7월 24일
No the answer is Z = +/- k
S H
S H 2019년 1월 28일
This is overdue, but it seems the later versions of Matlab can solve this equation properly.

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

카테고리

Help CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by