I have a vector p=[-3 -2 -1 0 1 2 3], and an expression like
$\psi_p=a~e^{ikp}+b~e^{-ikp}$ for $-3\leq p< 1$ and $\psi_p=c~e^{ikp}$ for $1\leq p\leq 3$; $a$, $b$ and $c$ have values which are given in my code below. The first issue is related to the logical indexing because p has negative and zero values. Secondly, how to write a for loop to implement the above statement? I want to create a vector $[\psi_{-3},\psi_{-2},~...~,\psi_2,\psi_3]$. The code I wrote is
k=2; p=[-3 -2 -1 0 1 2 3]; c=1; a=5; b=9;
psi3=c*exp(3*i*k);
psi2=c*exp(2*i*k);
psi_33 = a*exp(-1i*3*k)+b*exp(1i*3*k);
psi_22 = a*exp(-1i*2*k)+b*exp(1i*2*k);
psi_11 = a*exp(-1i*1*k)+b*exp(1i*1*k);
psi_0 = a+b;
psi_1 = c*exp(1i*k);
psi_2 = c*exp(1i*2*k);
psi_3 = c*exp(1i*3*k);
phi11=[psi_33,psi_22,psi_11,psi_0,psi_1,psi_2,psi_3]
Just looking for a more clean way to write so I can manipulate for even very large p say in 1000s. Thanks.