How to plot using finite diff. method

have two differential equations:
1st equation d^2P/dy^2 = k1(y)-k2 k1 and k2 are constants given, Lower Boundry y=0 P=80 - Upper Boundry y=80 P=120
2nd equation d^2P/dy^2 = -k1(y^2)+k2(y)-k3 k1,k2 and k3 are constants given, lower boundry y=0 P=30, upper boundry y=90 p=50
help with MetLab Code to plot the above functions using finite difference method for y=0 and y=80 increments of 1.
thank you

댓글 수: 8

Pierre A
Pierre A 2021년 4월 12일
thank you - I am a beginner - perhaps this might help? k1=.00457, k2=.00154 and k3=.025
Walter Roberson
Walter Roberson 2021년 4월 13일
The point is that we expect you to ask more specific questions, and (typically) to make a start at coding it.
Pierre A
Pierre A 2021년 4월 13일
I am having difficulty coding the differential equation using finite difference method - I could figure out the graphing, initial inputs etc. just having difficulty with the for next loop that would calculate the points using finite diff. method - can't figure out the code - if you could help that would be great.
Pierre A
Pierre A 2021년 4월 13일
I have done the googling the web and searching this forum - just trying to complete a Homework - I guess I will not be getting any help here also - thanks.
Walter Roberson
Walter Roberson 2021년 4월 13일
Hundreds of people have posted finite difference code, covering a number of different finite difference approaches. There is a File Exchange contribution giving explicit code for 5 different approaches. You did not say anything about which approach you needed, and you did not ask any specific question, and you did not post any code. None of us has the time to go back and forth with you asking you questions about what exactly you need and what you know already, and none of us has the time to build a custom tutorial for you on all the possible approaches in hopes that you might find one of them useful.
If you want to interpret "people who ask vague questions after being reminded to ask specific questions, end up getting vague responses" as "I guess I will not be getting any help here also", then that's up to you. You could have, for example, picked out two or three of the many searches you did, and posted them (or links to them), and asked "In this code, I do not understand why they... (whatever)?" or "In that code, I do not understand which part is calculating the derivative?" then that would give us something concrete to go on.
Pierre A
Pierre A 2021년 4월 13일
ok - here is the code below I was trying to use - the graph does not look correct.
L=150;
t=80;
k=0.0009478;
k2=0.04174
n=90;
nt=100;
dx=L/n;
dt=1;
alpha=k*dt/dx^2;
alpha1=k2*dt/dx
T0(1) = 91;
T0(end) = 149;
for j=1:nt
for i=2:n-1
T1(i)=T0(i)+alpha*(T0(i+1)-2*T0(i)+T0(i-1))-alpha1;
end
T0=T1;
end
plot(T1)

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

질문:

2021년 4월 12일

댓글:

2021년 4월 13일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by