On Mon, Apr 27, 2020 at 7:26 PM Thomas D. Dean <
address@hidden> wrote:
On 2020-04-27 14:58, 이태훈 wrote:
> Hi all
>
> I have 3 equations to integrate
> equation1
> I want to integrate equation1 numerically and put the solution to
> equation2 (see I(b,X))
>
>
> And than I should integrate equation2 numerically and put the solution
> to equation3
>
>
>
> I have coded what I explain to you. (The Y in this code is the x )
> But it is not running.
> Can you tell me what I did wrong?
>
> t0 = 0 ;
> y0 = 0 ;
> 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
> %% initializing Solution for I
> m = [0:0.5:3.14]
> I = [N+1,1]
> I(1)= I0
> %% 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).+(h.*A);
> 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
> plot(T,Y);
> disp(T)
>
What error messages do you see?
Tom Dean
I tried running this. One error is the line
fi = 20.*2.717.^(B.-D).*T(i));
which has an extra right parenthesis. It should be replaced with
fi = 20.*2.717.^(B.-D).*T(i);
In the block of code
%% 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).+(h.*A);
end
you are using the variable Y before you define it. You need to define Y first before you can do any calculation with it.
Are these the errors you've had so far?