COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Implicit method of a PDE using L.U multiplication

• Email
• Follow

```Hi every one, im new in here could you please help?
Im trying to compute the next step of nodes in a mesh,I have only the preview node.

U(n,m+1)=(q(n,m)+alpha(U(1,1)))/y(n,1); this equation is what i want to solve.
bellow is what i have created.

function IFDE(dx,dt,tmax)
N=round(1/dx);% N is the number of mesh-points.
M=round(tmax/dt);% M is the number of time steps
U=zeros(N+1,M+1);% this is the value of the option at a nodes (exercise price)
%The N+1 is the number of rows in the matrix.
%the M+1 is the number of columns.
%To create a row or a column vector we set the appropriate argument of zeros to one.
alpha=dt/(dx)^2;
alpha2=alpha^2;
% bellow are the initial conditions
U(2,1) = 10*exp((-0.005*dt));%boundary on the left of a put option
U(ceil((N+1)/2),1)=0;%boundary on the right of a put option
vetx = 0:dx:1;
for i=2:ceil((N+1)/2)
U(i,1)=2*vetx(i);
U(N+2-i,1)=2*vetx(i);
end
y(1,1)=1+2*alpha;
for n=2:N+1
y(n,1)= y(1,1)+alpha2/y(n-1,1);%this compute y(n)
end
a=zeros(N+1,1);% is the column vector with all entry zero except the first and last entry.
a(1,1)=alpha*(U(1,1));% first entry of the vector
a(N+1,1)=alpha*(U(N+2-i,1));%last entry of the vector
q(1,1)=a(1,1);
for n=2:N-1
q(n,1)=b(n,1)+alpha*(q(n-1,1)/y(n-1,1));%comput q(n)
end
U(1,1)=q(1,1)/y(1,1);
for m=1:M
for n=2:N
U(n,m+1)=(q(n,m)+alpha(U(1,1)))/y(n,1);
end
end

but when i call in commend window: U=IFDE(0.1,0.1,0.2)
I get this error.
??? Error using ==> IFDE
Too many output arguments..
will you see any error?
Thanks for taking time to read.
Regards Sal
```
 0

See related articles to this posting

```"Saliou " <sbarryfr@hotmail.co.uk> wrote in message <ic6mkj\$s0q\$1@fred.mathworks.com>...
> Im trying to compute the next step of nodes in a mesh,I have only the preview node.
>
> U(n,m+1)=(q(n,m)+alpha(U(1,1)))/y(n,1); this equation is what i want to solve.
>  bellow is what i have created.
>
> function IFDE(dx,dt,tmax)
> N=round(1/dx);% N is the number of mesh-points.
> M=round(tmax/dt);% M is the number of time steps
> U=zeros(N+1,M+1);% this is the value of the option at a nodes (exercise price)
> %The N+1 is the number of rows in the matrix.
> %the M+1 is the number of columns.
> %To create a row or a column vector we set the appropriate argument of zeros to one.
> alpha=dt/(dx)^2;
> alpha2=alpha^2;
> % bellow are the initial conditions
> U(2,1) = 10*exp((-0.005*dt));%boundary on the left of a put option
> U(ceil((N+1)/2),1)=0;%boundary on the right of a put option
> vetx = 0:dx:1;
> for i=2:ceil((N+1)/2)
>     U(i,1)=2*vetx(i);
>     U(N+2-i,1)=2*vetx(i);
> end
> y(1,1)=1+2*alpha;
> for n=2:N+1
>     y(n,1)= y(1,1)+alpha2/y(n-1,1);%this compute y(n)
> end
> a=zeros(N+1,1);% is the column vector with all entry zero except the first and last entry.
> a(1,1)=alpha*(U(1,1));% first entry of the vector
> a(N+1,1)=alpha*(U(N+2-i,1));%last entry of the vector
> q(1,1)=a(1,1);
> for n=2:N-1
>     q(n,1)=b(n,1)+alpha*(q(n-1,1)/y(n-1,1));%comput q(n)
> end
> U(1,1)=q(1,1)/y(1,1);
> for m=1:M
>     for n=2:N
>         U(n,m+1)=(q(n,m)+alpha(U(1,1)))/y(n,1);
>     end
> end
>
>  but when i call in commend window: U=IFDE(0.1,0.1,0.2)
> I get this error.
> ??? Error using ==> IFDE
> Too many output arguments..
>  will you see any error?
> Thanks for taking time to read.
> Regards Sal

You're trying to call it with an output argument (U) but none are assigned inside it.

function U = IFDE(dx,dt,tmax)
....
so that the function returns an argument

doc function
for a more thorough explanation.
```
 0

```Thanks, i manage to fix it by restarting the code with a different approach.
I also did not realise you have replied.
```
 0

`I received 1 st <a href="http://bestfinance-blog.com">loans</a> when I was 32 and this supported me very much. But, I need the sba loan as well. `
 0