フィルターのクリア

Integral operator in a for loop

17 ビュー (過去 30 日間)
amin rasoulof
amin rasoulof 2013 年 3 月 27 日
編集済み: Walter Roberson 2020 年 3 月 6 日
Hi folks! I am trying to calculate the integral of a function while it is in a loop,but MATLAB gives error. How can I change "v" each time? this is the code
f=@(y) sqrt(y)/(1+exp(y/v))
for v=-5:0.1:5
q(i)=integral(f,0,inf);
end
  6 件のコメント
Walter Roberson
Walter Roberson 2020 年 3 月 6 日
編集済み: Walter Roberson 2020 年 3 月 6 日
It gets confusing when the same question is posted in multiple places! https://www.mathworks.com/matlabcentral/answers/509422-double-integration-with-loop
José Anchieta de Jesus Filho
José Anchieta de Jesus Filho 2020 年 3 月 6 日
編集済み: José Anchieta de Jesus Filho 2020 年 3 月 6 日
I thought that this way it would be easier to understand. I'm sorry for this
dF = @(z1,r) 2.*pi.*v.*ro.*(Brt(z1,r).^2).*r; % v, ro they are scalar numbers
p1 = @(r) integral(@(z1) dF(z1,r),z0,z0+e,'ArrayValued',true);% e is also a scalar
F = integral(@(r) p1,ri,re,'ArrayValued',true);
c = F./v
that's my role in response to z0. what I need is for it to be calculated with the z0 varying
z0 = 0:0.001:0.03
for each variation of z0, I will have a new p1, a new F and, consequently, a new c. I want to plot a graph of z0 versus c

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

回答 (2 件)

Andrei Bobrov
Andrei Bobrov 2013 年 3 月 27 日
編集済み: Andrei Bobrov 2013 年 3 月 27 日
v = -5:.1:5;
f = @(y)sqrt(y)./(1+exp(y./v));
q = integral(f,0,inf,'ArrayValued',true);

Matt J
Matt J 2013 年 3 月 27 日
vdata=-5:0.1:5;
n=length(vdata);
q=zeros(1,n);
for i=1:n
v=vdata(i);
f=@(y) sqrt(y)/(1+exp(y/v));
q(i)=integral(f,0,inf);
end

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by