how to get a contour plot for a matrix with imaginary values

4 views (last 30 days)
an error pops up saying the values must be real
p1source=(A1*exp(-j*k0*r1source))./r1source; %pressure from source 1
p2source=(A1*exp(-j*k0*r2source))./r2source; %preassure from source 2
p3source=(A1*exp(-j*k0*r3source))./r3source; %pressure from source 3
Pm1=p1source+p2source+p3source; %total pressure from all three sources
figure(1)
contourf(1:1:10,1:1:6,(pm1));

Answers (1)

KSSV
KSSV on 3 Jan 2022
You can plot either ral, imaginary or absolute of the value.
contourf(1:1:10,1:1:6,real(pm1)); % to plot real part
contourf(1:1:10,1:1:6,imag(pm1)); % to plot imaginary part
contourf(1:1:10,1:1:6,abs(pm1)); % to plot absolute

Categories

Find more on Contour Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!