Ok, you are at least now getting close. Your code is still convoluted. And you have the wrong terms you create.
Look carefully at the term you need to create. It should apparently look like
You can multiply by 8, to cater to the 8 out front in the sum. But what you wrote is not that. Close. But not that. It still had sn in it, from the previous term.
As well, why are you computing count, but then returning n, which is just 1 less than count? Strange. Oh, I guess you are using n as the summation index, but it is not the number of terms you needed in the sum? But it is the number of terms.
Finally, you never actually initialized the approximation in any way at zero. Always initialize a sum variable that will accumulate a result. Just don't use a variable named sum.
And, oh. Learn to use semi-colons on your lines.
function [piapprox,k] = mySumPi(tol)
k = 0;
piapprox = 0;
while abs(piapprox-pi) >= tol
k = k + 1;
piterm = 8./((4*k-3)*(4*k-1));
piapprox = piapprox + piterm;
With a tolerance of 1e-2, I get
[piapprox,count] = mySumPi(1e-2)
The series you are using is not very rapidly convergent. Better than a sharp stick in the eye, but not incredibly much better.