Upsampling algorithm too slow
First, you should use informative variable names. For example, use "upsample_ratio" instead of x, "inSignal" instead of y etc. This will make your code much easier to read and understand.

Second, you should avoid using for loops in matlab if possible, and especially don't use nested for loops, since they take very long time in matlab.

Third, you overuse the variable y. Use intermediate variables to keep temporary and result values. 

Forth, your algorithm concept is wrong in case the upsampling ratio is not a whole number.

Specifically for your code, start by replacing the inner loops with array operations:

vec = length(y):-1:i+1;
y(vec+q) = y(vec);
y(i+1:1:i+1) = 0;