MATLAB: How create correct function

function

Hi I wrote something like that and I think it is a function but I got some errors when I run it. What is mistake?
function t = Aineq(k1,q,e,a,b)
m=input('input m=')
n=input('input n=')
q=sparse(m*n,m*n)
e=speye(m*n)
k1=-4*e
a=constraint12b(m,n)
b=constraint12c(m,n)
t=[k1 q e q;q k1 q e;a q e q;q a q e;b q -e q;q b q -e]
end
I point that constraint12b and constraint12c are functions separately and could be ran correctly.

Best Answer

Your function should be something like this
function t = Aineq(m,n)
q=sparse(m*n,m*n)
e=speye(m*n)
k1=-4*e
a=constraint12b(m,n)
b=constraint12c(m,n)
t=[k1 q e q;q k1 q e;a q e q;q a q e;b q -e q;q b q -e]
save this as Aineq.m, then if you want to run your function, you have to use another script or from Matlab windows command
n=10
m=20
t = Aineq(m,n)