You need to declare x
as a global variable in every scope (i.e. function/workspace) that you want it to be shared across. So, you need to write test1
as:
function test1()
global x;
x = 5;
end
You need to declare x
as a global variable in every scope (i.e. function/workspace) that you want it to be shared across. So, you need to write test1
as:
function test1()
global x;
x = 5;
end