- cumsum: https://www.mathworks.com/help/matlab/ref/double.cumsum.html
- trapz: https://www.mathworks.com/help/matlab/ref/trapz.html
How can I integrate a measurement signal into Simulink in an mFile?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I would like to integrate a Simulink signal with the value "1x1 double timeseries" in Matlab.
However, within an m-Function, integration using trapz or cumsum does not work.
I hope someone can help me here
0 Kommentare
Antworten (1)
Soumya
am 28 Mai 2025
Bearbeitet: Soumya
am 28 Mai 2025
The functions such as‘trapz’and ‘cumsum’are designed to operate on numeric arrays, rather than directly on‘timeseries’objects. To perform integration, you first need to extract the time and data vectors from your timeseries object.
Here is an example of how you can do that:
t = mySignal.Time;
x = mySignal.Data;
Additionally, these vectors may sometimes contain extra singleton dimensions, which can be removed using the‘squeeze’function to ensure compatibility with MATLAB’s numeric operations.
After this step, you can use the ‘trapz’ or the ‘cumsum’ function to integrate the data:
y=trapz(t,x);
y=cumsum(t,x);
For more information on these functions, you may find the following documentation helpful:
I hope this helps!
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!