I integrated fault current which is sine wave with its time period as an interval. But, i am getting value as an answer instead of getting 0.
Show older comments

F=0.05
ix = (Phasecurrent.Time >= F) & (Phasecurrent.Time <=F+0.020047);
Int = cumtrapz(Phasecurrent.Data(ix))
vpa(Int(end))
ans =
137031976.93982961773872375488281
4 Comments
Paul
on 7 Jan 2024
What does this command show:
Int = cumtrapz(PhaseCurrent.Time(idx),Phasecurrent.Data(ix))
Dyuman Joshi
on 7 Jan 2024
Edited: Dyuman Joshi
on 7 Jan 2024
In addition to Madhan's answer, also note that cumtrapz() is a numerical approximation instead of a proper integral and the data points you have do not seem to be smooth enough - there are slight unsmoothness (for a lack of a better phrase) near the maximas and minimas.
So even after using correct syntax, the answer might not be exactly 0.
A Lumbini
on 8 Jan 2024
Paul
on 8 Jan 2024
Why not just implement it in Simulink? Use a Clock, two Compare to Constant blocks, and an AND to output signal that is 1 (or true) over the desired interval and 0 otherwise. Multiply that signal with signal to be integrated and send that product into an Integrator. Make sure to use a variable step solver with zero crossing detection turned on, at least for the Compare to Constant and AND blocks, if not for the whole model.
Accepted Answer
More Answers (0)
Categories
Find more on Signal Attributes and Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
