Error using double Conversion to double from cvx is not possible

Hi all, I am very new to CVX (and Matlab). I am having the following problem. I am minimising the objective:


subject to the following for loop:

for i = 1:29
V >= 700;
CL(i) = (W(i).*g)/(0.5*density*(V^2)*S);
CL >= 0;
CD(i) = CDo + ((CL(i).^2)/(3.14*AR*e));
CD >= 0;
T = ((CD(i)/CL(i))*(W(i)*g))/1000;                    
T >= 0;
thisArray = [p1(1,i), p1(2,i); p1(1,i+1), p1(2,i+1)];
cp(i) = {thisArray};                                  
disp(i) = pdist(cp{i},'euclidean')*1000;                
disp >= 0;
Wf(i) = SFC*T*(disp(i)/V);
Wf >= 0;
W(i+1) = W(i)-Wf(i);

The following are given variables:

SFC = 0.94/60; g = 9.81; m = 77000; S = 122.60; CDo = 0.024;
W(1) = 77000; b = 34.10; e = 0.8; AR = (b^2)/S; density = 0.3494;

p1 is defined as a 3x30 matrix representing x (row 1) y (row 2) and z (row 3) coordinate positions.

When I run this I get the following error:

Conversion to double from cvx is not possible.

Error in pdist (line 142)

        X = double(X);

Error in fueloptimal (line 91)

    disp(i) = pdist(cp{i},'euclidean')*1000;

Can anyone please help?
Thank you all in advance!

FAQ: Why doesn’t CVX accept my problem? [READ THIS FIRST]

What is pdist? It is not a supported CVX function, that’s for sure.

If this is the function, then this model is not convex. CVX is not the right tool for your job. See the FAQ.

I used pdist to find the Euclidean distance between two consecutive points. I can’t use a basic equation because it involves a square root which is not accepted by CVX. I understand that the function is not convex but the rest of the model is. Is there another distance equation I can use?

I found a solution. I’m using the norm equation and it works:

disp(i) = norm([p1(1,i+1),p1(2,i+1)]-[p1(1,i),p1(2,i)])*1000;

Great, I’m glad you found a solution, though I assume you had to drop some of your nonconvex constraints to get it…