Adding a Scalar Value to One Item of a Vector
Model Description
This model demonstrates how you can take a scalar value and add it to one of the items of a vector using an expression. This method is compared to a doing this with another Data element vector.
Use the Vector constructor statement with an IF statement to look at a specific item of a vector. Use the "row" variable to point to a specific item of the array.
Here is the expression, in general terms:
vector(if(row = index, some_vector[index] + some_scalar, some_vector[row]))
The "vector" term is a global statement used to construct a new vector on the fly. If no vector name is provided, GoldSim assumes you mean the vector defined in the element you are working in. The "row" term is a local variable used in the scope of the vector constructor to reference each row index of the vector.
Model Files
Screen Captures
Main model view:
See Also