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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Geometry and Mesh에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!