How to solve 'Error using image Complex values are not supported. Specify the color data as numeric or logical values.'

27 visualizzazioni (ultimi 30 giorni)
Hi
I have attached my data S_OPT.mat having size SW_OPT (115 200) and VD (115 1);
The problem is some array in SW_OPT are complex number and I want to plot probability as given by my code:
x22 = [0.0:0.001:1]';
Prob_SW = zeros(length(VD), length(x22));
for i=1:length(VD)
Prob_SW(i,:) = ksdensity(SW_OPT(i,:),x22);
Prob_SW(i,:) = Prob_SW(i,:)/sum(Prob_SW(i,:));
end
figure(6), imagesc([0.0:0.001:1], VD, Prob_SW); xlabel('S_w (m/s)');
axis([1 1 1.888e+03 2.131e+03]); set(gca,'ytick',[1.888e+03:55:2.131e+03]);
set(gca,'xtick',[0:0.5:1]); set(gca,'FontSize',9); ylabel('Depth (m)'); colorbar;
set(gcf, 'position', [1200 285 200 410]);
colorbar;
But following error appears
Error using image
Complex values are not supported. Specify the color data as numeric or logical values.
Error in imagesc (line 52)
hh = image(varargin{:}, 'CDataMapping', 'scaled');
Error in UQ_PLOT_4D (line 195)
figure(6), imagesc([0.0:0.001:1], VD, Prob_SW); xlabel('S_w (m/s)');
How can I solve this problem? I want to obtain a figure like this

Risposta accettata

Jeffrey Clark
Jeffrey Clark il 15 Set 2022
@Nisar Ahmed, I don't have the toolbox for ksdensity but the imaginary parts of SW_OPT are insignificant relative to their real and abs values. I think you should instead be using abs(SW_OPT) and your imaginary problem will be resolved.

Più risposte (0)

Categorie

Scopri di più su Colormaps in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by