Error using sortrows in my optimisation script after for loop

Error using matlab.internal.math.sortrowsParseInputs Column sorting vector must contain integers with absolute value between 1 and the number of columns in the first argument. Error in sortrows (line 64) [col, nanflag, compareflag] = matlab.internal.math.sortrowsParseInputs(ismatrix(A),size(A,2),A,varargin{:}); Error in TLP (line 110) sol_sorted = sortrows(sol,17);

3 commentaires

Torsten
Torsten le 31 Jan 2024
Modifié(e) : Torsten le 31 Jan 2024
Before calling "sortrows", check whether "sol" is really a matrix or table of class "double" that has at least 17 columns.
Hi Torsten,
Thank you, but checked sol which has 8 column, but I still have the same error
% Dt = 4*((Fb/(4*rho_Water))-(Width - 2*Dc)*Hp)/(pi*Dc.^2);
if (GM>MetaC)%&& Dc < Cs && Dc>lpt && Dt>Hp && Hc>Dt
% data_feasible=[data_feasible; Dc, Hc, Hp, Mt, Dtd, DeckH, Dt];
W = MassT + Mt + 4*(Vc1+Vc2)*rhoCL + 4*Vn*rhoNd + 4*Vp*rhoPT + Nm*Vtd*rhoTD ;
% TMass = MassT + Mt + 4*(Vc1+Vc2)*rhoCL + 4*Vn*rhoNd + 4*Vp*rhoPT + Nm*Vtd*rhoTD ;
sol=[sol; Dt, DeckH, Dtd, Mt, Hp, Hc, Dc, W]; %#ok<AGROW> % Store the feasible solution
end
end
end
end
end
end
end
end
% sort the matrix of feasible solutions based on the objective (here vol, the third column)
sol_sorted = sortrows(sol,8);
% Select the first solution (which is the optimum after sorting all solutions based on the objective)
opt_sol=sol_sorted(1,:);
Torsten
Torsten le 31 Jan 2024
Modifié(e) : Torsten le 31 Jan 2024
Before calling "sortrows", insert the two lines of code
size(sol)
class(sol)
and tell us what MATLAB prints to console.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Data Type Identification dans Centre d'aide et File Exchange

Produits

Version

R2022b

Question posée :

le 31 Jan 2024

Modifié(e) :

le 31 Jan 2024

Community Treasure Hunt

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

Start Hunting!

Translated by