- #1
Cornelius
- 4
- 0
1. In the below code, I need to know how to ensure that the peaks end up near the middle. I also want to know how to calculate the end value of "u". Thanks!
2.
clear all
close all
clc
u = 1000*ones(1,200);
dt = 0.01;
dx = 1/201;
for i = 2:10/dt
dudt = diff(u(i-1,;
Du = 10*log(10*exp(-0.0001*u(i-1,);
dudt = diff(Du(1:end-1).*dudt);
u(i,:)= u(i-1,:);
u(i,2:end-1) = u(i,2:end-1)+dudt*dt;
u(i,1) = u(i,2)-10*(log(10*exp(-0.0001*u(i,1))))*(1-(log(10*exp(-0.0001*u(i,1))))/100)*dx;
u(i,end) = u(i,end-1)+10*(log(10*exp(-0.0001*u(i,end))))*(1-(log(10*exp(-0.0001*u(i,end))))/100)*dx;
hold on
plot(u(i,
end
3. I tried using "end/2" in the above expression, but it doesn't give me a suitable solution.
2.
clear all
close all
clc
u = 1000*ones(1,200);
dt = 0.01;
dx = 1/201;
for i = 2:10/dt
dudt = diff(u(i-1,;
Du = 10*log(10*exp(-0.0001*u(i-1,);
dudt = diff(Du(1:end-1).*dudt);
u(i,:)= u(i-1,:);
u(i,2:end-1) = u(i,2:end-1)+dudt*dt;
u(i,1) = u(i,2)-10*(log(10*exp(-0.0001*u(i,1))))*(1-(log(10*exp(-0.0001*u(i,1))))/100)*dx;
u(i,end) = u(i,end-1)+10*(log(10*exp(-0.0001*u(i,end))))*(1-(log(10*exp(-0.0001*u(i,end))))/100)*dx;
hold on
plot(u(i,
end
3. I tried using "end/2" in the above expression, but it doesn't give me a suitable solution.