Input Argument for contour must be real
22 views (last 30 days)
Show older comments
I have an error in contourf function : "Input arguments for contour must be real. Use the function REAL to get the real part of the inputs."
I've checked the input file ,the data are all real numbers. Here's the code.
Thanks for your help .
4 Comments
Walter Roberson
on 30 May 2020
contourf( X,Y, real( OD_MO), linspace( min(min(OD_MO)), max( max( OD_MO) ),40 ),'EdgeColor' , 'none' );
That tells us that you expect OD_MO to have complex values, as otherwise you would not real() it. But what are min() and max() of complex values? Can you guarantee that if you take min() of a complex number that the result is real valued?
Answers (1)
Walter Roberson
on 30 May 2020
rOD = real(OD_MO(:));
minOD = min(rOD);
maxOD = max(rOD);
contourf( X,Y, real( OD_MO), linspace( minOD, maxOD, 40), 'EdgeColor' , 'none' );
4 Comments
Walter Roberson
on 30 May 2020
Whether or not imaginary portions are saved has nothing to do with the problem you reported about contourf saying that the inputs must be real.
See Also
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!