Thank’s a lot. I have saved both functions as script and run the code but didn’t worked. Below are the errors for the codes. I don’t know how to define the parameters. Isn’t it enough to write just umax=0.08 or I0=1:?? And please tell me If there are any other problem. Thank you
>> mu_tilde
warning: function 'mu_tilde' defined within script file '/Users/taehoonlee/mu_tilde.m' error: 'umax' undefined near line 23 column 29 error: called from mu_tilde at line 23 column 23 >> IbX
error: 'I0' undefined near line 27 column 21 error: called from IbX>@<anonymous> at line 27 column 23 integral at line 114 column 7 IbX at line 28 column
Code Fn1: a=3; b=3; r=0.0984; X=9.8; I0=1;
function IbX_return_value = IbX(IbthetaX,theta) IbthetaX = @(theta) I0.*exp( -a.*X.*( b.*cos(theta).+sqrt(r.^2-b.^2.*sin(theta).^2) ) ); IbX_return_value = (1/pi).*integral(IbthetaX,0,pi); end
Fn2: b=3; umax=3; r=0.0983;
function mu_tilde_return_value = mu_tilde(b) mu_tilde_integrand = @(b) b.*(IbX./(IbX.+KM)); mu_tilde_return_value = (2.*umax./r.^2).*integral(mu_tilde_integrand,0,r); end
Dear all Thank you for the answer. I think the triplequad doesn’t help. Because the equations are all independent. I want to loop the whole process as below. Eq1 integration ==> solution from Eq1 ==> insert to Eq2 ==> integration of Eq2==> solution from Eq2 ==> insert to Eq3==> get “X” and insert it again to Eq1.
I correct my codes. But get this error. The question : Is this the right way to loop? If it’s not please tell me how to do it. Thank you/ > Eulernew
m = 3.1400 I =
51 1
I =
1 1
A = -0.0046009 A = -0.046009 error: Y(3): out of bound 2 error: called from Eulernew at line 26 column 8
Code : t0 = 0 ; y0 = 0.1 ; tEnd = 5; h= 0.1; N = (tEnd.-t0)./(h); D=1.1; r=0.0984; ka=3; z=10; umax=0.08; km=3; I0=1; a=3; b=3; Q=pi; %% initializing Solution for I m = [3.14] I = [N+1,1] I(1)= I0 Y = [N+1,1]'; Y(1) = y0; %% solving euler Ex for i=1:N A=(I0./3.14).*exp(-a).*(Y(i)).*(((b.*cos(m)).+((r.^2).-((b.^2).*(sin(m)).^2)).^0.5)) I(i+1) = I(i).+(Q.*A); Y(i+1) = Y(i).+(h.*fi); end %% initializing Solution for u R = [0:0.5:3.14] U = [N+1,1] U(1)= 0 %% solving euler Ex for i=1:N B=(2.*(umax./(r.^2))).*((b.*(A)))./(A.+km) U(i+1) = U(i).+(h.*B); end %%Initializing Solution T = [t0:h:tEnd]'; Y = [N+1,1]'; y(1) = y0; %% Solving using Euler's Explicit Method for i= 1:N fi = 20.*2.717.^(B.-D).*T(i); Y(i+1) = Y(i).+(h.*fi); end
Explanation
equation1 <스크린샷 2020-04-27 오후 8.54.55.png> I want to integrate equation1 numerically and put the solution to equation2 (see I(b,X))
<스크린샷 2020-04-27 오후 8.55.03.png> And than I should integrate equation2 numerically and put the solution to equation3
<스크린샷 2020-04-27 오후 8.58.44.png>
I see - you need to integrate to obtain I(b,X) and then integrate a function of that integral.
It would be best to define intermediate functions when you need them. For example, to obtain μ I would use the following pair of functions.
function mu_tilde_return_value = mu_tilde(X) mu_tilde_integrand = @(X) b.*(I(b,X)./(I(b,X)+KM)); mu_tilde_return_value = (2.*mumax./r.^2).*integral(,0,r); end
function IbX_return_value = IbX(b,X) IbthetaX = @(theta) I0.*exp( -a.*X.*( b.*cos(theta)+sqrt(r.^2-b.^2.*sin(theta).^2) ) ); IbX_return_value = (1/pi)*integral(IbthetaX,0,pi); end
Does that help?
|