« GTable2D » : différence entre les versions
Aller à la navigation
Aller à la recherche
Aucun résumé des modifications |
Aucun résumé des modifications |
||
Ligne 21 : | Ligne 21 : | ||
And you will obtain this ... | And you will obtain this ... | ||
[[File:GTable2D.jpg]] | [[File:GTable2D.jpg]] | ||
To get the content of this table, we will have to use the <font color=#4169E1>getAbsValues()</font>, <font color=#4169E1>getOrdValues()</font> and <font color=#4169E1>getValues()</font> methods: | To get the content of this table, we will have to use the <font color=#4169E1>getAbsValues()</font>, <font color=#4169E1>getOrdValues()</font> and <font color=#4169E1>getValues()</font> methods: |
Version du 5 mai 2017 à 13:45
GENIUS allows also to display (and read/write !) two dimension tables. The idea is to be able to manage one tabulated function depending on two parameters : f(xi, yi) as, for example a volume depending on pressure (P) and temperature (T) => V = f(P,T)
To do it, we must use GTable2D class to store data. Using it is relatively simple as shown ont the example below :
// Unit lists
GUnit[] unitVolume = {new GMetricUnit("m^3"), new GMetricUnit("dm^3")};
GUnit[] unitPressure = {new GMetricUnit("Pa"), new GMetricUnit("mPa")};
GUnit[] unitTemperature = {new GTemperatureUnit("K"), new GTemperatureUnit("°C")};
double[][] vol = { {50. , 100.0, 150.0},
{60. , 110.0, 120.0},
{75. , 125.0, 175.0} };
double[] pres = { 1., 10.0, 20.0 };
double[] temp = { 250.0, 300.0, 350.0 };
GTable2D volTable = new GTable2D (vol, pres, temp,
"Volume", "Pressure", "Temperature",
unitVolume, unitPressure, unitTemperature);
And you will obtain this ...
To get the content of this table, we will have to use the getAbsValues(), getOrdValues() and getValues() methods:
double[] abs = volTable.getGTable().getAbsValues();
double[] ord = volTable.getGTable().getOrdValues();
double[][] val = volTable.getGTable().getValues();