フィルターのクリア

Single value after integration instead of matrix

1 回表示 (過去 30 日間)
Özgür Alaydin
Özgür Alaydin 2022 年 2 月 24 日
回答済み: Özgür Alaydin 2022 年 3 月 5 日
Dear all,
I have a code as given below.
I want to integratethis function and in the end i want to have numeric matrix. But when i run the code i am getting single value. What i want is having a one-dimensional matrix, each row should be calculated from the integration.
When i run the code i am getting "0" as a result.
Normally z is step function with a intensity 0.228. Middle of z is 0 it gives a function like ;
In the end i assign z -> alfa*sin(wt) and want to integrate over t. I should have a matrix which should give sligtly different shape then given above (bended side trough the middle).
Please help....
Vb1=0.228; dz=1E-11;
Ltot = 20e-9;
z=-Ltot/2:dz:Ltot/2;
L = 10e-9; alfa=5e-9; w=1E+14; T=2*pi/w;
t= 0:T/(length(z)-1):T;
z =z + alfa.*sin(w.*t);
Vb =@(t) ((z<-L/2).*(Vb1) + (z>-L/2).*(Vb.*(z./(2*Ltot)+0.25)) + (z>L/2).*(Vb1));
V0 = (1/T).*integral(Vb,0,T)
  6 件のコメント
Torsten
Torsten 2022 年 2 月 24 日
編集済み: Torsten 2022 年 2 月 24 日
If you set z = z + alfa.*sin(w.*t), z is an array of values - the integration variable t has disappeared.
So Vb does no longer depend on t.
Maybe you want this:
Vb1=0.228; dz=1E-11;
Ltot = 20e-9;
z=-Ltot/2:dz:Ltot/2;
L = 10e-9; alfa=5e-9; w=1E+14; T=2*pi/w;
for i=1:numel(z)
fz =@(t) z(i) + alfa.*sin(w.*t);
Vb = @(t) ((fz(t)<-L/2).*(Vb1) + (fz(t)>-L/2).*(Vb1.*(fz(t)./(2*Ltot)+0.25)) + (fz(t)>L/2).*(Vb1));
V0(i) = (1/T).*integral(Vb,0,T,'ArrayValued',true)
end
Özgür Alaydin
Özgür Alaydin 2022 年 2 月 25 日
Dear Torsten
Thanks a lot.
This is exactly what i want. I have learnt one more command (numel).
Regards.

サインインしてコメントする。

採用された回答

Özgür Alaydin
Özgür Alaydin 2022 年 3 月 5 日
Vb1=0.228; dz=1E-11;
Ltot = 20e-9;
z=-Ltot/2:dz:Ltot/2;
L = 10e-9; alfa=5e-9; w=1E+14; T=2*pi/w;
for i=1:numel(z)
fz =@(t) z(i) + alfa.*sin(w.*t);
Vb = @(t) ((fz(t)<-L/2).*(Vb1) + (fz(t)>-L/2).*(Vb1.*(fz(t)./(2*Ltot)+0.25)) + (fz(t)>L/2).*(Vb1));
V0(i) = (1/T).*integral(Vb,0,T,'ArrayValued',true)
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumerical Integration and Differentiation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by