to compare the floating value of a signal with file.mat signal

Hi,
In a simulink simulation i've "recorded" a signal in a file.mat. Now, in an other simulation i need to compare a new signal with file.mat-signal (i'll call file.mat-signal as m(t)).
For example with the floating value f(t) of the new signal (in the new simulation) i need to know the time t such that:
abs(f(t)-m(t)) < some tolerance value
I know that t is an element of the file.mat matrix, but i don't know how i can do the comparison in simulink.

回答 (1 件)

Seth Popinchalk
Seth Popinchalk 2011 年 3 月 30 日

0 投票

You can build the equation using blocks from the Math Operations and Logic and Bit Operations libraries.
You will need an ABS block, a Sum Block and you could use the Compare to Constant to make the comparison to the tolerance value. This produces a signal that will be 1 when the condition is true. That can be used to trigger or enable a conditionally executed subsystem.

3 件のコメント

cyberdyne
cyberdyne 2011 年 3 月 30 日
I've some problem to make it read file.mat. I don't know why the blocks don't see From File Block output like a constant matrix as it is.
If i build
abs(f(t)-m(t)) < some tolerance value
How can i meet "t value" that respect condition above ?
Kaustubha Govind
Kaustubha Govind 2011 年 3 月 30 日
Does your data in the MAT-file conform to the required format for From File (see http://www.mathworks.com/help/toolbox/simulink/slref/fromfile.html)? Also see the heading "Simulation Time Hits That Have No Corresponding MAT-File Time Stamps".
cyberdyne
cyberdyne 2011 年 3 月 30 日
I've loaded mat-file. Inside it there are time value with 1s decimation (0 1 2 3...) as 1st row and there are signal value samples as 2nd row. If i plot 1st row-->2nd row, it returns me original signal as it is.
I tried to record time of the 1st simulation in an other mat-file and:
FromFile(time.mat)----->SubSystem(with Trig.)---->display
FromFile(Signal.mat)---(+)>Sum--->ABS---CompareToConst.(<0.01)-->trig.
SignalToCompare--------(-)|
But display doesn't show value of time of time.mat

この質問は閉じられています。

質問済み:

2011 年 3 月 29 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by