(adsbygoogle = window.adsbygoogle || []).push({}); 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.

1. The problem statement, all variables and given/known data

2. Relevant equations

3. The attempt at a solution

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Homework Help: MATLAB question

**Physics Forums | Science Articles, Homework Help, Discussion**