How to use linprog when i have variable ('A')= cell

Hello, I get the following error when i try to run the linprog command : error using linprog (line 144) LINPROG requires the following inputs to be of data type double: 'A'. All the other variables i have are double (f,b,Aeq,beq,lb) except from A which is a 35x1 cell.What can i do in order to convert A to type double.

Answers (1)

A=cell2mat(A)

7 Comments

I can't use cell2mat because of the dimensions. I get the following error :Dimensions of matrices being concatenated are not consistent.
post your code to see how A is used in linprog command
v=1.003*10^(-6);
k=0.0015;
Hman=110.6;
QD=LinkFlows;
f=cell(length(find(LinkFlows>0)),1);
Re=cell(length(find(LinkFlows>0)),1);
Hf=cell(length(find(LinkFlows>0)),1);
HeadLoss=cell(length(find(LinkFlows>0)),1);
NodeElevations=d.getNodeElevations;
NodeElevations=NodeElevations(1:end-1);
LeastPressure=Hman-NodeElevations-35;
for ii=1:length(find(LinkFlows>0))
Re{ii}=4.*QD(ii)./(pi.*DiameterCell{ii}.*v);
f{ii}=0.25./[log((5.74./(Re{ii}.^(0.9)))+(k./(3.7.*DiameterCell{ii})))].^2;
Hf{ii}=((0.083.*f{ii}.*QD(ii).^2)./((DiameterCell{ii}./1000).^5));
end
for j=2:length(find(LinkFlows>0))
HeadLoss{1}=[[Hf{1}]];
HeadLoss{j}=Hf{j};
HeadLoss{j}=[[HeadLoss{j}] [HeadLoss{j-1}]]
%%Where A=HeadLoss a cell with a differnt number of values in each cell
And what line gives the error?
i dont get an error from this, i just can't use the A variable in the lin prog command because its a cell. What can i do to fix this?
How do you want to use it with linprog? explain your problem?
there are 35 nodes in a network and i have to find the optim solution for diameters.I find a range of different diameter for each pipe, each diameter represents a cost.I have an f vector with (1,112) differnt values of costs for pipes , A which is the cell with Headloss for each pipe in a network that is add up ,b is a vector (1,35) with the pressure that is needed in each node , Aeq is the length constraint for each pipe is a matrix (35,112) with zeros and 1, every pipe may be consisted of differnt diameter (example a pipe of 200 m may be x1+ x2+ x3 possible diameters),beq is the length of each pipe and lb is that each x should be greater than zero.

Sign in to comment.

Categories

Asked:

on 26 Aug 2016

Commented:

on 26 Aug 2016

Community Treasure Hunt

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

Start Hunting!