MATLAB: Surf doesnt work when plot 3d non continuous function

surf

Hi fellows,
I have wrote a function cara, as you seen nextly in the code that it is a non-continuous one.
function [ eu ] = cara( lb1,lb2,lb3,c1,c2 )
d1=[1.2,0.8,0.9];
d2=[1.3,1.5,0.4];
tempeu=0;
r=0.08;
w1=c1*d1(1,1)+c2*d2(1,1)
w2=c1*d1(1,2)+c2*d2(1,2)
w3=c1*d1(1,3)+c2*d2(1,3)
if (w1==min([w1;w2;w3]))
tempeu=-(1-lb2-lb3)*exp(r*((d1(1,1)-1)*c1+(d2(1,1)-1)*c2))-...
p2*exp(r*((d1(1,2)-1)*c1+(d2(1,2)-1)*c2))-...
p3*exp(r*((d1(1,3)-1)*c1+(d2(1,3)-1)*c2));
elseif (w2==min([w1;w2;w3]))
tempeu=-lb1*exp(r*((d1(1,1)-1)*c1+(d2(1,1)-1)*c2))-...
(1-lb1-lb3)*exp(r*((d1(1,2)-1)*c1+(d2(1,2)-1)*c2))-...
lb3*exp(r*((d1(1,3)-1)*c1+(d2(1,3)-1)*c2));
elseif (w3==min([w1;w2;w3]))
tempeu=-lb1*exp(r*((d1(1,1)-1)*c1+(d2(1,1)-1)*c2))-...
lb2*exp(r*((d1(1,2)-1)*c1+(d2(1,2)-1)*c2))-...
(1-lb1-lb3)*exp(r*((d1(1,3)-1)*c1+(d2(1,3)-1)*c2));
end
eu=tempeu;
end
And then I want to use surf to plot function and my code is
x1 = linspace(-100,100,RESOLUTION);
y1 = linspace(-200,200,RESOLUTION);
[c1,c2] = meshgrid(x1,y1);
eu = cara(0.3,0.3,0.3,x1,y1);
%eu=arrayfun(@(x)f(x),x(1:end));
y1=surfc(c1,c2,eu);
y1=surfc(c1,c2,eu);
Then there is an error message saying that "The surface Z must contain more than one row or column.". I dont really understand this and also don't know how to solve this problem. Is there anyone could help me with this?
Really appreciated!

Best Answer

You're calling surfc with data eu that isn't the same size as c1 and c2.