10-05-2009 07:03 AM
I'm a beginner trying to implement a Model Predictive Controller (MPC) controller in SystemBuild for my final thesis project. This involves a bunch of matrix operations being performed and some resulting matrices being sent to a UserCode Fortran script, solving a Quadratic Programming problem. At the moment I have two specific, and I hope quite simple, questions:
It should be noted that the solutions must work with the AutoCode feature.
Any advice or source of information is appreciated, I find the SystemBuild User Guide a bit thin.
10-06-2009 06:53 PM
The SystemBuild summer block is an element-by-element summer.
To add two matricies, set the number of branches to 2 (the default) and set the number of outputs to match the number of matrix elements.
To make it easier to connect matricies between SystemBuild blocks, You should set the block InputPins and OutputPins modes to vector and set inputnames and outputlabels as vectors labels.
Here is an SBA script example you can cut and paste into the Xmath command line which adds two constant blocks (matrix) using a summer.
[,y] = sim("matrixsum",t)
Reading Matlab data into Xmath is tricky because the Matlab save format is closed and changing.
If you can write out you Matlab data in ASCII format and remove and headers or labels and are
just left with just numbers seperated by spaces. You could use the Xmath read command
to load it into Xmath as a matrix.
A = read("$XMATH/demos/read_ex.ascii",10,10,"ascii")?
Check out Xmath Math User Guide page C-16 Loading In External Data (read)