matlab - How to plot Complex system related to its imaginary parts -


i've defined complex symbolic system :

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 returned following results:

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)) 

now how possible plot(x,sys(x)) or (x,imaginarypart(x)) in complex surface?

for plotting it's required use range of values. so, using x = + b*i:

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

enter image description here

i did have add dots (i.e. element wise multiplication) equation make work.

additionally contourf suggested in comment @andrasdeak:

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

i used meshgrid of -10:0.01:10 here more resolution:

enter image description here

if reluctant hand-copy solution add element wise multiplication dots, can resort loops:

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

this delivers same result, pros , cons both. it's slower matrix-multiplication, i.e. adding dots equation, not require manipulating output hand.


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -