what's wrong in this algorithm? is a "numerical instability" problem?
3 次查看(过去 30 天)
显示 更早的评论
I've created an algorithm that implement the real time subspace tracking, but the simulink results and the matlab results are different. I need to implement the algorithm on simulink, cause I use D-space, which needs simulink source.
The correct results are the matlab ones, I fragmented the algorithm and I have discovered that the origin of the differences is in one single simulink block, which does simple operations, as matrix moltiplications, matrix transpose, and add/remove column from matrix.
In particular, there is an error about 10^-12 between matlab and simulink, after matrix moltiplication.
The matrix is a 400X10, I've initialized it as eye(400,10), the data type is double.
I've already written on this forum, and you answer to me that the problem may be a numerical instability of my algorithm. But the fragment of the algorithm which gives me problem, is very simple. The input signal is a sum of 3 sine waves. After there is an if subsystem ( I have to fill a mobile vector, before doing some math operations). I use 2 s-function builder :first s-function is very simple, there is only 1 assignment operation. The second one implements some sequences of givens rotations, but the code is correct: I've tested it.
I have a feedback after the s function who implement givens rotations, and I use a memory block to store in memory the matrix for the next step.
I've observed that when the matrix is filled only by ones and zeros, the error (between simu e matlab) is 10^-12. After the first step, the matrix is filled by other numbers, and after the first matrix moltiplication, the result begins to diverge from the matlab result.
I think that this divergence increase step by step, and it becomes 10^3 (in about 15 steps), but not more than 10^3 in the next steps. The final results in the simulink results is not acceptable.
How can I resolve this problem? What is wrong?
P.s. I use some switch blocks, may be an important detail.
thank you for the answers.
0 个评论
回答(1 个)
Jan
2013-8-2
Did you check the validity of the Simulink block until you are sure, that they do not contain a bug? "matrix multiplications, matrix transpose, and add/remove column from matrix" could be prone to rounding errors e.g. when multiplications are performed in a different order. But a bug is possible also.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!