GTable2D

De Wiki
Aller à : navigation, rechercher

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 ...


GTable2D.jpg


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();


Return to the introduction ↑ Go to the next page →