I am struggling to understand how to setup some indexing problem in MATLAB. If my entire domain is defined from 1 to N with a padding of two cells. So say my internal domain (domain without padded cells) from 2 to N-2, then if I want to calculate some values at the "interfaces" of the cells instead at the cells, how can I setup this on MATLAB? For example I have the following code for the internal domain that I would like to change my indicies to the interfaces?
My set up is like:
I keep getting the error:
Index in position 2 exceeds array bounds
The code for example:
function [ U_L, U_R] = MUSCL(U,N,NEQ )
denom_L = (U(i,j) - U(i,j-1));
denom_R = (U(i,j+2) - U(i,j+1));
denom_L = sign(denom_L+1e-64)*max(delta, abs(denom_L));
denom_R = sign(denom_R+1e-64)*max(delta, abs(denom_R));
r_L = (U(i,j) - U(i,j-1))/denom_L;
r_R = (U(i,j+2) - U(i,j+1))/denom_R;
U_L(:,j) = U(:,j)+0.5*theta_R.*(U(:,j)-U(:, j-1));
U_R(:,j) = U(:,j+1)-0.5*theta_L.*(U(:,j+2)-U(:,j+1));
How can I find U_L, U_R, r_L, r_R at j+1/2 ??