Can't figure out the error in my pcolor line, keep getting color data input must be a matrix error
20 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Tyler Stephen Kuehn
am 23 Sep. 2020
Kommentiert: Tyler Stephen Kuehn
am 23 Sep. 2020
xvalues =[-15.0:0.25:15.0]';
gvalues = gzx(xvalues,p,z); %evaluates xvalues for a defined function for a constant p & z (function is defined later in the code)
Xdata = [xvalues, gvalues];
XLB = [3.5; 7500]
XUB = [7.0; 12500]
%... Calculate grid to plot hump function
opt=0;
DX1=0.03;
DX2=10;
[x1, x2] = meshgrid(XLB(1):DX1:XUB(1),XLB(2):DX2:XUB(2));
[M0,N0]=size(x1);
xx1=x1(:);
xx2=x2(:);
n=size(xx1,1);
for ii=1:n
fplot(ii)=costfunct([xx1(ii);xx2(ii)],Xdata);
end
fplot=reshape(fplot,M0,N0);
%plot
hf = figure();
colormap jet;
pcolor(x1,x2,fplot);
shading interp
hold on
2 Kommentare
Akzeptierte Antwort
Steven Lord
am 23 Sep. 2020
Please run this command immediately before the line where you call pcolor and show us the output from just before the pcolor call that throws the error.
whos x1 x2 fplot
My suspicion is that fplot was initialized to something that's not numeric (like a sym array) and can't be converted into a double array in order to be used in pcolor, something like x in the example below.
x = sym('x', [10 10]);
pcolor(1:10, 1:10, x)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Graphics Object Programming finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!