I have plotted a signal in Simulink and now i want to write a code to integrate that signal over the limits? can anyone help me with this please
2 次查看(过去 30 天)
显示 更早的评论
clc;
clear all;
open('tranmissionfault.slx');
sim('tranmissionfault.slx');
syms t
P=int(Phasecurrent,t,0,0.008)
采纳的回答
madhan ravi
2024-1-6
编辑:madhan ravi
2024-1-6
edit: Thanks @Paul, i overlooked it, yes the same goal can be achieved in Simulink using a switch block, but not going in detail into it, since the OP's intention is to use MATLAB code
17 个评论
madhan ravi
2024-1-6
cumtrapz(phasecurrent.Data(phasecurrent.Time < 0.008))
Assuming phasecurrent is logged as timeseries through To workspace block. Use trapz() if you want the answer to be a scalar.
madhan ravi
2024-1-6
cumtrapz(phasecurrent.Data((phasecurrent.Time >= lower_limit) & (phasecurrent.Time <= upper_limit)))
A Lumbini
2024-1-6
Thank you so much for your time sir, i have been working on it for a long time as part of my semester project and i don't know much about matlab.
Your inputs were very helpful
A Lumbini
2024-1-6
I have to implement DFT algorithm under fault conditions with selective intervals and i have to write a code for it
A Lumbini
2024-1-6
I used your code which lead to another question
if we integrate sine wave by taking its timeperiod as an inteval we need to get 0.But, i am getting a value
Paul
2024-1-6
Based on the code in the question, it appears that the OP wants to integrate the signal over the interval 0 < t < 0.008. The "Integrator Limited" doesn't do that. Rather it integrates the input signal over the whole simulation, but limits the integral itself to the specified limits.
madhan ravi
2024-1-6
编辑:madhan ravi
2024-1-6
ix = (out.sinewave.Time >= 0) & (out.sinewave.Time <= 4); % lower limit 0 and upper limit 4
Int = cumtrapz(out.sinewave.Data(ix))
vpa(Int(end)) % very close to zero
Int =
0
0.1545
0.6029
1.3013
2.1813
3.1569
4.1324
5.0124
5.7108
6.1592
6.3138
6.1592
5.7108
5.0124
4.1324
3.1569
2.1813
1.3013
0.6029
0.1545
-0.0000
ans =
-0.0000000000000016375
Paul
2024-1-6
My mistake. For some reason I didn't see you were dot indexing into PhaseCurrent, i.e., PhaseCurrent.Data.
However, shouldn't the cumtrapz use the two argument form?
ix = (out.sinewave.Time >= 0) & (out.sinewave.Time <= 4); % lower limit 0 and upper limit 4
Int = cumtrapz(out.sinewave.Time(ix),out.sinewave.Data(ix))
madhan ravi
2024-1-6
the form you have used is also correct, as we do the indexing directly into the data itself, i just use the first snytax mentioned in the docu
Paul
2024-1-6
Except the first syntax assumes that the independent variable has unit spacing, which is not likely to be the case for the time vector of logged signal from a simulink model. The time spacing of the logged signal might not even be uniform if the solver is variable step.
madhan ravi
2024-1-6
编辑:madhan ravi
2024-1-6
Yes, i just noticed that specialzed power system's powergui uses Continuos method. I always work with Discrete models hence didn't notice it. Thanks for noticing it.
A Lumbini
2024-1-6
Thank you sir, got the answer
clc;
clear all;
open('tranmissionfault.slx');
sim('tranmissionfault.slx');
ix = (Phasecurrent.Time >= 0.012) & (Phasecurrent.Time <= 0.032016);
Int = cumtrapz(Phasecurrent.Data(ix))
vpa(Int(end))
Int =
1.0e+04 *
0
-0.0146
-0.0599
-0.1199
-0.1939
-0.2938
-0.4152
-0.5528
-0.7004
-0.8513
-1.0025
-1.1506
-1.2893
-1.4123
-1.5146
-1.6055
-1.6826
-1.7309
-1.7481
-1.7335
-1.6882
-1.6282
-1.5542
-1.4543
-1.3328
-1.1953
-1.0477
-0.8968
-0.7456
-0.5974
-0.4588
-0.3358
-0.2335
-0.1426
-0.0654
-0.0172
0.0000
ans =
0.15362797623171786653983872383833
A Lumbini
2024-1-7
Sir, i got 0.15 approximately when i integrate the sine wave
But,then i tried the same after the fault and i am getting huge value
F=0.05
ix = (Phasecurrent.Time >= F) & (Phasecurrent.Time <=F+0.020047);
Int = cumtrapz(Phasecurrent.Data(ix))
vpa(Int(end))
ans =
137031976.93982961773872375488281
更多回答(0 个)
社区
另请参阅
标签
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)