首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何绘制与虚部相关的复杂系统

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

Stack Overflow用户
提问于 2016-02-06 16:11:17
回答 1查看 138关注 0票数 7

我定义了一个复杂的符号系统:

代码语言:javascript
复制
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返回了以下结果:

代码语言:javascript
复制
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))作为一个复杂的表面?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-02-06 16:30:22

要绘制它,需要使用一系列的值。所以,使用x = a + b*i

代码语言:javascript
复制
[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中的建议,使用comment by @AndrasDeak

代码语言:javascript
复制
figure
contourf(a,b,result,51) %// plots with 51 contour levels
colorbar

我在这里使用了一个网格-10:0.01:10来获得更多的分辨率:

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

代码语言:javascript
复制
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

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

票数 13
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35243186

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档