How to plot real and complex parts of a function in 3d?

10 vues (au cours des 30 derniers jours)
jeremy morgan
jeremy morgan le 29 Août 2017
i have an assignment that reads as such:
My task is to plot 3 sub plots showing G in terms of real, complex, and the magnitude of the transfer function. I assume by magnitude, they mean the original plot with real and complex combined, if not then I will have to rework my equation. I have found a way, I think to graph the 3d plot by using resources in previously asked questions. My code looks as such:
clear
[x,y] = meshgrid(-10: 0.5: 10);
s = x + 1i*y;
G = abs(((s+2) ./ ((s.^2) + 6.*s + 18)));
figure;
surf(x,y,G)
Which results in an image as such:
My question is how do I split this graph into 2 subplots where I am showing the real and the complex independently? I don't see that type of question either in the Help section or in previously posted questions...

Réponses (2)

Shyamali Abeysooriya
Shyamali Abeysooriya le 28 Nov 2021
clear
[x,y] = meshgrid(-10: 0.5: 10);
s = x + 1i*y;
G = abs(((s+2) ./ ((s.^2) + 6.*s + 18)));
figure;
surf(x,y,G)

KSSV
KSSV le 29 Août 2017
You can seperate the real part and complex part using real and imag.
real_part = real(s) ;
imag_part = imag(s) ;

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by