Epanet 2.2 toolkit for matlab
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello, i am doing a simulation with the toolkit of epanet for matlab. The code is the following:
clear all
%pc fisso
run('C:\Users\Alfio Spectre\Documents\MEGA\MEGAsync\5°Anno\Second Semester\materiale\Epanet_Toolkit\start_toolkit');
% Assuming you have already initialized and opened the EPANET network
d = epanet('CASALNUOVO.inp');
% Get the total number of nodes in the network
numNodes = d.getNodeCount;
% Inizializza una cell array per le categorie di domanda per ogni nodo
allNodeDemandCategories = cell(numNodes, 1);
% Inizializza una cell array per le base demands relative ad ogni categoria di domanda per ogni nodo
allNodeBaseDemands = cell(numNodes, 1);
% Loop attraverso ogni nodo e ottieni le categorie di domanda
for i = 1:numNodes
% Ottieni l'ID del nodo corrente
nodeID = d.getNodeNameID(i);
% Ottieni l'indice del nodo corrente
nodeIndex = d.getNodeIndex(nodeID);
% Ottieni il numero di categorie di domanda per il nodo corrente
numCategories = d.getNodeDemandCategoriesNumber(nodeIndex);
% Inizializza una cell array per le categorie di domanda del nodo corrente
nodeDemandCategories = cell(1, numCategories);
% Inizializza una cell array per le base demands relative ad ogni categoria di domanda del nodo corrente
nodeBaseDemands = cell(1, numCategories);
% Check se ci sono categorie di domanda per il nodo corrente
if numCategories > 0
% Loop attraverso le categorie di domanda del nodo corrente
for j = 1:numCategories
% Ottieni la categoria di domanda corrente
category = d.getNodeJunctionDemandName(nodeIndex, j);
% Assegna la categoria di domanda alla cell array
nodeDemandCategories{j} = category;
% Ottieni la base demand relativa alla categoria di domanda corrente
baseDemand = d.getNodeBaseDemands(nodeIndex, j);
% Assegna la base demand alla cell array
nodeBaseDemands{j} = baseDemand;
end
end
% Assegna le categorie di domanda del nodo corrente alla cell array principale
allNodeDemandCategories{i} = nodeDemandCategories;
% Assegna le base demands relative ad ogni categoria di domanda del nodo corrente alla cell array principale
allNodeBaseDemands{i} = nodeBaseDemands;
end
% Close the EPANET network
d.unload;
At least i obtained the vectors allNodeBaseDemands and allNodeDemandCategories but the values inside of them, respectively a numeric value and just a letter value, have been produced as a cell.
For example regarding the vector allNodeBaseDemands i obtain for the first 10 nodes:
1x1 cell
1x1 cell
1x1 cell
1x1 cell
1x1 cell
1x1 cell
1x5 cell
1x1 cell
1x1 cell
1x1 cell
1x2 cell
Considering the last value 1x2 cell, if i open it i obtain:
1x2 cell 1x2 cell
If i open the first cell i obtain:
0.00428099976852536 0.0427980013191700
And those are the values that i would like to see as i instantly open the above vector. Exactly the same is for the other vector.
I've tried to use every single command i could use to convert cell vectors to other types of values, but anything worked. Please help me, im stucked here since 4 days ago...
To run this code you should have Epanet 2.2 installed and my model CASALNUOVO is attached to this post.
The link to install this toolkit is the following:
0 commentaires
Réponses (1)
Walter Roberson
le 9 Fév 2024
It is not possible to create a numeric vector that has 1 column in place but 2 columns when needed.
You can do things like
horzcat(allNodeBaseDemands{:})
to get out a numeric row vector, but such a row vector would not have internal divisions to show you where the cells of length 2 were.
Perhaps you want to
celldisp(allNodeBaseDemands)
0 commentaires
Voir également
Catégories
En savoir plus sur Environmental Science dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!