MATLAB Answers

## How to solve a complex equation which has one equation but two real variables?

Asked by Feng Zhou

### Feng Zhou (view profile)

on 14 Feb 2019
Latest activity Answered by Walter Roberson

### Walter Roberson (view profile)

on 14 Feb 2019
Normally, a set of equations that have the same number of unknowns can be solved. However, an complex eqaution with two unknowns are possible to be solved. For example, a complex equation like : x+y*j = a+ b*j, can be solved by x = a, and y = b, because the real part and imaginary part correspond to each other.
Now, my question is how to do it with MATLAB solve function. A typical scanerio is the propagation constant solution in EM wave. The original eqaution is:
Kc = omiga* sqrt(u*(eps-j*sigma/omiga));
we would like to solve the equation into Kc = k_real -j* k_img. k_real and k_img are the unknowns in the equation.

#### 0 Comments

Sign in to comment.

## 2 Answers

Answer by Torsten

### Torsten (view profile)

on 14 Feb 2019
Edited by Torsten

### Torsten (view profile)

on 14 Feb 2019

Does that help ?
>> syms z k
>> z0 = 1+3*1I;
>> a = solve(z==k*z0,z)
a = (sym) k*(1 + 3*I)
>> real(a)
ans = (sym) re(k) - 3*im(kc)
>> imag(a)
ans = (sym) 3*re(k) + im(kc)

madhan ravi

### madhan ravi (view profile)

on 14 Feb 2019
Feng Zhou's answer moved here:
I get the results like this. There are also something strange in my Matlab. I suppose there are something wrong in my MATLAB。
>> syms z k
>> z0 = 1+3*1i;
>> a = solve(z==k*z0,z)
a =
z
madhan ravi

### madhan ravi (view profile)

on 14 Feb 2019
>> syms z complex
% ^^^^^^^---- add the assumption
>> syms k
>> z0 = 1+3*1i;
>> a = solve(z==k*z0,z)
a =
k*(1 + 3i)
>> real(a)
ans =
real(k) - 3*imag(k)
>> imag(a)
ans =
imag(k) + 3*real(k)
>>
Walter Roberson

### Walter Roberson (view profile)

on 14 Feb 2019
complex is the default assumption and does not need to be added. Instead add real to the variables intended to be real valued.

Sign in to comment. ### Walter Roberson (view profile)

Answer by Walter Roberson

### Walter Roberson (view profile)

on 14 Feb 2019

split the equation into two parts by taking real() and imag() so you end up with two equations in two unknowns .

#### 0 Comments

Sign in to comment.