Crank-nicolson method, MATLAB Programming

Assignment Help:

 

clear

tic

L=1;

T=0.2;

nust=2000;

dt=T/nust;

n=40;

dx=L/n;

 

r=1;

 omega=10:10:5000;%Store Range of Frequencies for Simulation

u=zeros(n+1,nust+1);%Initialize the grid (Space along rows/dim1& time along cols/dim2)

% Bar Boundary Condition

time=zeros(1,nust+1);%Time Elapsed Vector

for k=1:nust+1

u(1,k)=0;

u(n+1,k)=0;

time(k)=(k-1)*dt;

end

% Bar Initial Condition

x=zeros(n+1,1);%Length Vector

fori=1:n+1

x(i)=(i-1)*dx;

u(i,1)=sin(pi*x(i));

end

%constructing the Matrix in the right side

ar(1:n-2)=r;

br(1:n-1)=2-2*r;

cr(1:n-2)=r;

Mr=diag(br,0)+diag(ar,-1)+diag(cr,1);

 

%constructing the Matrix in the left side

al(1:n-2)=-r;

bl(1:n-1)=2+2*r;

cl(1:n-2)=-r;

Ml=diag(bl,0)+diag(al,-1)+diag(cl,1);

%aa=Ml\Mr;

 

% Crank Nicolson Implementation

u_sol=zeros(length(u(:,1)),length(u(1,:)),length(omega));

forll=1:length(omega)

for k=2: nust

        C=0.5*dt*(cos(omega(ll)*k*dt)+cos(omega(ll)*(k+1)*dt))*ones(length(2:n),1);

uu=u(2:n,k-1);

        u(2:n,k)=inv(Ml)*((Mr*uu)+C);

end

u_sol(:,:,ll)=u;

    clear uu;

end

 

figure;

subplot(2,1,1); mesh(x,time,u_sol(:,:,1)')

title(['Solution for omega=',num2str(omega(1))]);

subplot(2,1,2); mesh(x,time,u_sol(:,:,end)')

title(['Solution for omega=',num2str(omega(end))]);

xlabel('x-axis');

ylabel('Temperature');

toc

The code you have provided me at that time was giving the out of the whole process( as a plot ) which isgood but we cannot specify a point in the rod to find the temperature , for example if we need to know the temperature at the distance 0.5 ( we know the total length is 1) there is no way to get it . so what I need is the following :

We have a rod with a length of 1 and we want to know the temperature at the center of the rod ( we may change the point we want to know ) and the output must be a number not a plot , I mean I want the MATLAB to tell me the temperature at the specified point.


Related Discussions:- Crank-nicolson method

Aquifer simulation of the groundwater, An environmental consulting firm is ...

An environmental consulting firm is conducting a site investigation on an abandoned industrial site that is 200 m by 150 m in size (Fig. 1). A number of piezometers were installed

A matlab program to produce a map of the route, Micro-mouse is an engineeri...

Micro-mouse is an engineering design competition created by IEEE in the late 1970s. Small robotic "mice" solve a 16x16 cell maze. The mice are completely autonomous and must find t

#title.the number of pixels related to the actual phase, #question.i want t...

#question.i want to know the number of pixels related to the actual phase value and want to separate the zero phase valued pixels from the image..

Design and implement binary digital modulation, Design and implement Binary...

Design and implement Binary digital modulation for a specific input signal frequency, sampling frequency and signal level for binary frequency shift keying (BFSK) by applying MATLA

Plot the poles and zeros of the filter using zplane, A filter described by ...

A filter described by the equation:    y(n) = x(n) + x(n-1) + 0.9 y(n-1) - 0.81 y(n-2) (a) Find the transfer function H(z) for the filter and find the poles and zeros of the fil

Tropical forest carbon balance, As shown in Figure 1, Ecosystem carbon (C) ...

As shown in Figure 1, Ecosystem carbon (C) cycles in a tropical forest can be modeled using three "compartments":  aboveground (AG), belowground (BG), and soil organic matters (SOM

Midpoint circle, drow midpoint circle for scan converting acircle in matlab...

drow midpoint circle for scan converting acircle in matlab

Wireless, can i getting wirless programing in matlab

can i getting wirless programing in matlab

Image forgery detection , i have a problem in doing my project which detect...

i have a problem in doing my project which detects image forgery detection using resampling technique any one please help in writing my program

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd