本文整理汇总了Java中com.jmatio.types.MLStructure.setField方法的典型用法代码示例。如果您正苦于以下问题:Java MLStructure.setField方法的具体用法?Java MLStructure.setField怎么用?Java MLStructure.setField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jmatio.types.MLStructure
的用法示例。
在下文中一共展示了MLStructure.setField方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createMLStruct
import com.jmatio.types.MLStructure; //导入方法依赖的package包/类
/** Create ML Structure with data for a channel
* @param index Index of channel in model
* @param name Channel name
* @param times Time stamps
* @param values Values
* @param severities Severities
* @return {@link MLStructure}
*/
private MLStructure createMLStruct(final int index, final String name,
final List<Instant> times,
final List<Double> values,
final List<AlarmSeverity> severities)
{
final MLStructure struct = new MLStructure("channel" + index, new int[] { 1, 1 });
final int N = values.size();
final int[] dims = new int[] { N, 1 };
final MLCell time = new MLCell(null, dims);
final MLDouble value = new MLDouble(null, dims);
final MLCell severity = new MLCell(null, dims);
for (int i=0; i<N; ++i)
{
setCellText(time, i, TimestampHelper.format(times.get(i)));
value.set(values.get(i), i);
setCellText(severity, i, severities.get(i).toString());
}
struct.setField("name", new MLChar(null, name));
struct.setField("time", time);
struct.setField("value", value);
struct.setField("severity", severity);
return struct;
}
示例2: testMLStructureFieldNames
import com.jmatio.types.MLStructure; //导入方法依赖的package包/类
@Test
public void testMLStructureFieldNames() throws IOException
{
//test column-packed vector
double[] src = new double[] { 1.3, 2.0, 3.0, 4.0, 5.0, 6.0 };
//create 3x2 double matrix
//[ 1.0 4.0 ;
// 2.0 5.0 ;
// 3.0 6.0 ]
MLDouble mlDouble = new MLDouble( null, src, 3 );
MLChar mlChar = new MLChar( null, "I am dummy" );
MLStructure mlStruct = new MLStructure("str", new int[] {1,1} );
mlStruct.setField("f1", mlDouble);
mlStruct.setField("f2", mlChar);
Collection<String> fieldNames = mlStruct.getFieldNames();
assertEquals( 2, fieldNames.size() );
assertTrue( fieldNames.contains("f1") );
assertTrue( fieldNames.contains("f2") );
}
示例3: putBusDataIntoMLStructure
import com.jmatio.types.MLStructure; //导入方法依赖的package包/类
private void putBusDataIntoMLStructure(BusData busData, MLStructure buses, int i) {
LOGGER.debug("Preparing mat data for bus " + busData.getBusId());
// nome
MLChar nome = new MLChar("", busData.getBusName());
buses.setField("nome", nome, 0, i);
// codice
MLChar codice = new MLChar("", busData.getBusId());
buses.setField("codice", codice, 0, i);
// ID
MLInt64 id = new MLInt64("", new long[]{busData.getBusIndex()}, 1);
buses.setField("ID", id, 0, i);
// type
MLInt64 type = new MLInt64("", new long[]{busData.getBusType()}, 1);
buses.setField("type", type, 0, i);
// Vnom
MLDouble vNom = new MLDouble("", new double[]{busData.getNominalVoltage()}, 1);
buses.setField("Vnom", vNom, 0, i);
// V
MLDouble v = new MLDouble("", new double[]{busData.getVoltage()}, 1);
buses.setField("V", v, 0, i);
// angle
MLDouble angle = new MLDouble("", new double[]{busData.getAngle()}, 1);
buses.setField("angle", angle, 0, i);
// Vmin
MLDouble vMin = new MLDouble("", new double[]{busData.getMinVoltage()}, 1);
buses.setField("Vmin", vMin, 0, i);
// Vmax
MLDouble vMax = new MLDouble("", new double[]{busData.getMaxVoltage()}, 1);
buses.setField("Vmax", vMax, 0, i);
// P
MLDouble p = new MLDouble("", new double[]{busData.getActivePower()}, 1);
buses.setField("P", p, 0, i);
// Q
MLDouble q = new MLDouble("", new double[]{busData.getReactivePower() }, 1);
buses.setField("Q", q, 0, i);
}
示例4: putGeneratorDataIntoMLStructure
import com.jmatio.types.MLStructure; //导入方法依赖的package包/类
private void putGeneratorDataIntoMLStructure(LoadData loadData, MLStructure loads, int i) {
LOGGER.debug("Preparing mat data for load " + loadData.getLoadId());
// estremo_ID
MLInt64 estremoId = new MLInt64("", new long[]{loadData.getBusIndex()}, 1);
loads.setField("estremo_ID", estremoId, 0, i);
// estremo
MLChar estremo = new MLChar("", loadData.getBusId());
loads.setField("estremo", estremo, 0, i);
// codice
MLChar codice = new MLChar("", loadData.getLoadId());
loads.setField("codice", codice, 0, i);
// conn
int connected = 0;
if (loadData.isConnected()) {
connected = 1;
}
MLInt64 disp = new MLInt64("", new long[]{connected}, 1);
loads.setField("conn", disp, 0, i);
// P
MLDouble p = new MLDouble("", new double[]{loadData.getActvePower()}, 1);
loads.setField("P", p, 0, i);
// Q
MLDouble q = new MLDouble("", new double[]{loadData.getReactvePower()}, 1);
loads.setField("Q", q, 0, i);
// V
MLDouble v = new MLDouble("", new double[]{loadData.getVoltage()}, 1);
loads.setField("V", v, 0, i);
}
示例5: putStochasticVariablesIntoMLStructure
import com.jmatio.types.MLStructure; //导入方法依赖的package包/类
private void putStochasticVariablesIntoMLStructure(StochasticVariable stochasticVariable, MLStructure stochVars, int i) {
LOGGER.debug("Preparing mat data for stochastic variable " + stochasticVariable.getId());
// id
MLChar id = new MLChar("", stochasticVariable.getId());
stochVars.setField("id", id, 0, i);
// type
MLChar type = new MLChar("", stochasticVariable.getType());
stochVars.setField("type", type, 0, i);
}
示例6: writeMatlabFile2
import com.jmatio.types.MLStructure; //导入方法依赖的package包/类
public void writeMatlabFile2() throws Exception
{
// Example values
final VType[] values = new VType[10];
for (int i=0; i<10; ++i)
values[i] = new ArchiveVNumber(VTypeHelper.getTimestamp(null), AlarmSeverity.NONE, "OK",
ValueFactory.displayNone(),
Math.exp(-((5.0-i)*(5.0-i))) );
// Turn values into Matlab data
final int[] dims = new int[] { values.length, 1 };
final MLDouble value = new MLDouble(null, dims);
final MLCell time = new MLCell(null, dims);
final MLCell severity = new MLCell(null, dims);
final MLCell status = new MLCell(null, dims);
for (int i=0; i<values.length; ++i)
{
value.set(VTypeHelper.toDouble(values[i]), i);
setCellText(time, i, TimestampHelper.format(VTypeHelper.getTimestamp(values[i])));
setCellText(severity, i, VTypeHelper.getSeverity(values[i]).toString());
setCellText(severity, i, VTypeHelper.getMessage(values[i]));
}
final MLStructure struct = new MLStructure("channel0", new int[] { 1, 1 });
struct.setField("value", value);
struct.setField("time", time);
struct.setField("severity", severity);
struct.setField("status", status);
// Write to file
final MatFileIncrementalWriter writer = new MatFileIncrementalWriter("mat_file2.mat");
writer.write(struct);
writer.close();
}
示例7: testMLStructure
import com.jmatio.types.MLStructure; //导入方法依赖的package包/类
/**
* Test <code>MatFileFilter</code> options
* @throws IOException
*/
@Test
public void testMLStructure() throws IOException
{
//array name
//file name in which array will be storred
String fileName = "mlstruct.mat";
File outFile = temp.newFile( fileName );
//test column-packed vector
double[] src = new double[] { 1.3, 2.0, 3.0, 4.0, 5.0, 6.0 };
//create 3x2 double matrix
//[ 1.0 4.0 ;
// 2.0 5.0 ;
// 3.0 6.0 ]
MLDouble mlDouble = new MLDouble( null, src, 3 );
MLChar mlChar = new MLChar( null, "I am dummy" );
MLStructure mlStruct = new MLStructure("str", new int[] {1,1} );
mlStruct.setField("f1", mlDouble);
mlStruct.setField("f2", mlChar);
//write array to file
ArrayList<MLArray> list = new ArrayList<MLArray>();
list.add( mlStruct );
//write arrays to file
new MatFileWriter( outFile, list );
//read array form file
MatFileReader mfr = new MatFileReader( outFile );
MLStructure mlArrayRetrived = (MLStructure)mfr.getMLArray( "str" );
assertEquals(mlDouble, mlArrayRetrived.getField("f1") );
assertEquals(mlChar, mlArrayRetrived.getField("f2") );
}