You do not explain how you are calling the function, but that is likely to be the problem. Perhaps you are trying to call it by copy-and-pasting the function definition and trying to run that?:
[sys,x0,str,ts] = spacemodel(t,x,u,flag)
The function requires four input arguments: you cannot just "run" it (e.g. by clicking the big green "Run" button) or "run" the file, you have to call it with all four input arguments, which have to be variables that exist in the workspace, e.g.:
A = 2;
B = 2;
C = 3;
function [sys,x0,str,ts] = spacemodel(A,B,C,1)
All well-written code also includes a help section at the beginning which explains what the code does, and specifies the input and output arguments. Note that this code will throw errors for some different flag input values when not all of the output arguments are defined... this is not very well written code.