I'm new to Matlab (coming from Python), and I'm trying to figure out the following matrix $A$ given 2 input arrays, $a = [a_0, a_1, ... , a_{n-1}]$, and $b = [b_1, b_2, ... , b_n]$.
I tried diag(a) - diag(sqrt(b)) - diag(sqrt(b)) going off another MSE post I read, but this doesn't seem to work. What's the correct way to do this in MATLAB? I would just create $n$ arrays and fill them up to represent columns in Python, but I'm sure there's a much smarter way to do that in MATLAB. Thank you.

Check out the matlab page for the diag command. You need to use two arguments: diag(v,k) places the elements of vector v on the kth diagonal. So, something like A = diag(v,0)+diag(sqrt(b),-1)+diag(sqrt(b),1).