Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Implicit method of a PDE using L.U multiplication

Subject: Implicit method of a PDE using L.U multiplication

From: Saliou

Date: 19 Nov, 2010 20:28:03

Message: 1 of 4

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

Subject: Implicit method of a PDE using L.U multiplication

From: Sean de

Date: 19 Nov, 2010 21:00:23

Message: 2 of 4

"Saliou " <sbarryfr@hotmail.co.uk> wrote in message <ic6mkj$s0q$1@fred.mathworks.com>...
> 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

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

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


doc function
for a more thorough explanation.

Subject: Implicit method of a PDE using L.U multiplication

From: Saliou

Date: 19 Dec, 2010 01:25:06

Message: 3 of 4

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

Subject: Implicit method of a PDE using L.U multiplication

From: LaverneCummings

Date: 30 Dec, 2010 11:02:16

Message: 4 of 4

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.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us