Change the value of PDE solution spatial indices

1 次查看(过去 30 天)
Dear all,
I have solved the partial differential equitation of the diffusion equation (first order in time and second order in spatial parameter) for two light sources separated by a distance d. The solution in the blue solid line (in the attached picture) can be seen for a certain time step. The red solid line is the same solution but multiplied by a factor.
My question is: How can I change the values of spatial indices of the multiplied solution matrix in a way that:
  • the indices between N=0 to N/4 and the indices between N/2 and 3N/4 are shifted to the left (with a certain amount, a) and
  • the indices between N/4 and N/2 and the indices between 3N/4 and N are shifted to the right (with the same certain amount, a).
I was thinking of writing the following code:
for i = 1 : N/4 & i = N/2 : 3N/4
TLeftShifted = NewT1(k,i-a)+NewT2(k,i-a);
end
for j = N/4 : N/2 & j = 3N/4 : N
TRightShifted = NewT1(k,j+a)+NewT2(k,j+a);
end
plot(x,TLeftShifted+TRightShifted)
where NewT1,NewT2 are the PDE solutions in the red solid line, k is a certain time step, a is the shifted amount and i,j are the spatial indices.
I'm wondering (although the code didn't run properly) if this code, in principle, is correct!
Many thanks,
Lama

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Geometry and Mesh 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by