Result1D Object

This object offers access and manipulation functions to 1D results.

When this object is constructed an argument specifies what result will be represented by this object. The corresponding data is read from file and stored within the memory of this object.

As an Result1D object represents a signal it stores x-values and the corresponding y-values. If, for instance, the object represents a magnitude over frequency, the x-values are the frequency values and the y-values are the corresponding magnitude values.

All data is stored in arrays so that access to the values is possible by specifying an zero-based index.

Initialization, File Operation

Construction

An Result1D object can be created as follows:

 

From within

dim objName as object

set objName = Result1D("adapt_error")

 

From an external progam

dim app As Object

set app = CreateObject("CSTStudio.Application")

dim mws = app.OpenFile("D:\Examples\example.mod")

 

dim objName as object

set objName = mws.Result1D("adapt_error")

 

While ”adapt_error” is the name of the result data the Result1D object should contain.

 

Initialize ( long n )

Initializes an empty Result1D object with the specified dimension n.

 

Load ( name sObjectName )

Loads a 1D result. sObjectName is the signal file name extension for the signal to be loaded.

 dim app As Object

 set app = CreateObject("CSTStudio.Application")

 dim mws as Object

 set mws = app.NewMWS

 dim res as object

 set res = mws.Result1D("")

 res.Load("adapt_error")

Note: The names used in the ResultTree do not necessarily correspond to the file names.

 

LoadPlainFile ( filename sObjectName )

Loads an external 1D result stored in the file sObjectName. If the file name sObjectName starts with a '^' the project name will automatically be added such that the corresponding signal of the current project will be loaded.

sObjectName may be a signal file of any source. It may have an arbitrary header, followed by the signal data organized in two columns.

 

Save ( name sObjectName )

Saves the object with the given filename. Note, that like in the LoadPlainFile method, the project name is added if the first character is a '^'. If the filename is blank the data is saved with name of the previous loaded file.

 

AddToTree ( name sTreePath )

Inserts the Result1D object into the tree at the folder specified by sTreePath. NOTE: Save the Result1D object before adding it to the tree to set correct path.

 

DeleteAt ( enum type )

Defines the lifetime of the result object.

enum type

meaning

"never"

The result will be never deleted.

"rebuild"

Deletion during model update. (default)

"solverstart"

A solver start will delete the result.

"truemodelchange"

A parameter change will delete the results.

  

SetAsResult ( bool switch )

If switch is True, the result object is treated like a normal solver result item.

 

InsertAsLastItem

If switch is True, .AddToTree inserts the Result1D Object at the end of the subfolder into the tree.

1D to 1D Operations

Copy Result1D Object

Returns a copy of the object.

 

Add / Subtract ( Result1D Object oObject )

Adds / subtracts the components in oObject  to/from the calling object's components. The result will be stored in the calling object. Before calling this method please make sure that the calling object and oObject contain compatible data (same number of samples, same values of the independent variable).

 

ScalarMult ( double dFactor )

Scales the Result1D Object with the given factor.

 

ComponentMult / ComponentDiv ( Result1D Object oObject )

Multiplies / divides the components in oObject  with/by the calling object's components. The result will be stored in the calling object. Before calling this method please make sure that the calling object and oObject contain compatible data (same number of samples, same values of the independent variable).

 

ResampleTo ( double min, double max, long nSamples )

Resample the result to a given number of samples between a minimum and maximum value. The new data samples are calculated by a linear interpolation of the original data samples.

 

MakeCompatibleTo ( Result1D Object oObject )

Re-samples the result in the calling object to make it compatible to the sampling of oObject. The new data samples are calculated by a linear interpolation of the original data samples.

1D to 0D Operations

ScalarProd ( Result1D Object oObject ) double

Performs a scalar product between two Result1D objects. The result will be returned as a double value.

 

GetGlobalMaximum / GetGlobalMinimum long

Returns the index of the overall maximum / minimum of the y-values.

 

GetMaximumInRange / GetMinimumInRange ( double x1, double x2 ) long

Returns the index to the maximum / minimum y-value that can be found between x1 and x2.

 

GetMaximumInIndexRange / GetMinimumInIndexRange ( long i1, long i2 ) long

Returns the index to the maximum / minimum y-value that can be found between two x-values referenced by the indices i1 and i2.

 

GetFirstMaximum / GetFirstMinimum ( double yLimit ) long

GetNextMaximum / GetNextMinimum ( double yLimit ) long

Returns the index to the first / next maximum / minimum y-value. The parameter yLimit defines a minimum difference between the found local maximum/minimum y-value and the previous and next local minimum/maximum y-value. If no further maximum/minimum could be found the returned index will be -1.

 

GetMeanValue double

Returns the mean value of the Result1D object's y-values.

 

GetSigma double

Returns the deviation of the Result1D object's y-values.

 

GetIntegral double

Returns the integral of the Result1D object.

 

GetNorm double

Returns the Euclidean norm of the Result1D object.

Local Operations:

GetX / GetY ( long index ) double

SetX / SetY ( long index, double dValue )

Sets / returns the x/y-value at the specified index in the Result1D object.

 

SetXY ( long index, double xValue, double yValue )

Sets the x- and  y-value at the specified index in the Result1D object.

 

SetXYDouble ( long index, double xValue, double yValue )

GetXYDouble ( long index, double_ref xValue, double_ref yValue )

Sets / returns the x- and  y-value at the specified index in the Result1D object.

Note, that these methods in contrast to .SetXY do only accept double parameters and no expressions.

 

AppendXY ( double xValue, double yValue )

Appends a new pair of values to the end of the result object.

 

GetClosestIndexFromX ( double dValue ) long

Returns the index of the x-value stored in the Result1D object that is closest to the specified value.

General Settings

Title / Xlabel / Ylabel ( string name )

Defines the title / x-axis label / y-axis label of the result.

 

GetTitle / GetXlabel / GetYlabel string

Returns the title / x-axis label / y-axis label of the result. This function works only for user added tree result objects.

 

GetN long

Returns the total number of value pairs stored in the Result1D object.

Example

This example creates two Result1D objects. One from the current project and one from an external project. The difference of the last values from the two objects is output in a message box.

 

Dim ThisResult As Object                   'object for the current project result

Dim ExtResult As Object                    'object for the external project result

Set ThisResult = Result1D("adapt_error")   'project name and extension will be added automatically

Set ExtResult = Result1D("")

ExtResult.LoadPlainFile("ExtProj^adapt_error.sig")

Dim d As Double

d = ThisResult.GetY(ThisResult.GetN-1) - ExtResult.GetY(ExtResult.GetN-1)

MsgBox Str$(d)