how to use an integral function inside a for loop? i need to find the value of function that chages as i chages .then using this values i need to find another integral.

조회 수: 1 (최근 30일)
r0 =0.1
u =[1:7]'
Q =zeros(length(u),1)
E =zeros(length(Q),1)
for i =1:length(u)
Q(i,1) =0.023*(r0^(-1/4))*((u(i))^(-14/4))
f =@(Q) (Q(i)).^(0.3)
E(i,1) =integral(f,1,7)
end
  댓글 수: 3
Aparna Sekhar
Aparna Sekhar 2024년 6월 5일
Hi Thank you for your respone.Im new to matlab so there may be many mistakes
Q(u)=0.023*r0^(-1/4)*u^(-14/4)
E(u1)= integral from u0 to u2 [Q(u)^(0.3)]du
where u is a range of numbers
u1 is between u0 and u2
Torsten
Torsten 2024년 6월 5일
E(u1)= integral from u0 to u2 [Q(u)^(0.3)]du
You define E as a function of u1, but u1 does not appear on the right-hand side.

댓글을 달려면 로그인하십시오.

답변 (1개)

Alan Stevens
Alan Stevens 2024년 6월 5일
Are you looking for something like this?
r0 =0.1;
u =[1:7]';
Q =zeros(length(u),1);
E =zeros(length(Q),1);
Q = @(x)0.023*(r0^(-1/4))*(x.^(-14/4));
f = @(x) Q(x).^0.3;
for i =1:length(u)
u0 = 1; u2 = u(i);
E(i,1) =integral(f,u0,u2);
end
disp(E)
0 0.2611 0.4097 0.5133 0.5927 0.6569 0.7107

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by