如何绘制与其虚部相关的复杂系统

How to plot a complex system related to its imaginary parts

我已经定义了复杂的符号系统:

syms x 
sys(x) = ((10+1.*i.*x))/(20+(5.*i.*x)+((10.*i.*x).^2))+((1.*i.*x).^3); 
ImaginaryPart = imag(sys)
RealPart = real(sys)

MATLAB 返回了以下结果:

ImaginaryPart(x) =

- real(x^3) + imag((10 + x*1i)/(- 100*x^2 + x*5i + 20))


RealPart(x) =

- real(x^3) + imag((10 + x*1i)/(- 100*x^2 + x*5i + 20))

现在怎么可能 plot(x,sys(x))plot(x,ImaginaryPart(x)) 作为一个复杂的曲面?

为了绘图,需要使用一系列值。所以,使用 x = a + b*i:

[a,b] = meshgrid(-10:0.1:10); %// creates two grids
ComplexValue = a+1i*b;        %// get a single, complex valued grid
CompFun = @(x)(- real(x.^3) + imag((10 + x.*1i)./(- 100.*x.^2 + x.*5i + 20))); %// add dots for element wise calculation
result = CompFun(ComplexValue); %// get results
pcolor(a,b,result) %// plot
shading interp %// remove grid borders by interpolation
colorbar %// add colour scale
ylabel 'Imaginary unit'
xlabel 'Real unit'

我确实必须在你的等式中添加点(即元素明智的乘法)才能使它起作用。

此外 contourf as suggested in the :

figure
contourf(a,b,result,51) %// plots with 51 contour levels
colorbar

为了更清晰,我在这里使用了 -10:0.01:10 的网格:

如果您不愿意手动复制解决方案以添加元素明智的乘法点,您可以求助于循环:

grid = -10:0.1:10;
result(numel(grid),numel(grid))=0; %// initialise output grid
for a = 1:numel(grid)
    for b = 1:numel(grid)
        x = grid(a)+1i*grid(b);
        result(a,b) = ImaginaryPart(x);
    end
end

这提供了相同的结果,但各有利弊。它比矩阵乘法慢,即比在方程中加点慢,但它不需要手动操作输出。