The variable a is defined in base workspace and hence, the error is because of the unavailability of variable a in function workspace. To share the data from base workspace with function workspace, you may make the variable a global.
global a
a = 1;
You also need to declare a as global in the function
function y = multi(x)
global a
y = a*x;
end
You may refer the following documentation for different practices of sharing data between workspaces
You may refer the following docmentation for differences between base and function workspace