Removing complex numbers from a set of data
92 次查看(过去 30 天)
显示 更早的评论
I am trying to plot a set of data as a surf plot. The y and x data are fine. However, the z data comes in the form of a complex number. I am trying to zero all of the complex parts so that i can plot it.
y = ydata;
x = xdata;
z = dat.smx; %getting the data from a structure array
z =complex(real(z),0.);
surf(x,y,z)
This acheives what i want and gives me my 192x4096 of only real numbers but the variable is still saved as a complex double so matlab still does not let me plot it.
z(imag(z) ~= 0) = 0;
I tried another way with the above line, which does also remove the imaginary part and does make it a normal double which can be plotted. But it also ends up completely zeroing all but two rows of my data.
763996.405269850 + 0.00000000000000i -6378786.63933523 + 0.00000000000000i
830122.423191093 - 394079.620750282i -5091297.01649812 + 2603687.55800279i
967512.178415854 - 1059879.31296563i -2457122.99646261 + 3059394.68904817i
752434.554058071 - 2280059.15542211i -896237.599749785 + 1334068.00008166i
-658985.067753466 - 3695451.52098837i -1627383.69202439 - 594734.648456007i
My data looks like a larger version of above
Any help is appreciated
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!