so let say I have two files fileA.m & fileB.m in fileA.m I have this code
function fileA() global dataX; dataX = 100; end
in fileB.m I want to use if to check the value this is what I have in fileB.m
function fileB() if dataX == 100 fprintf('Value is %f \n' , dataX); else fprintf('Value is NOT %f \n' , dataX); end end
however I'm having problem every time I run fileB.m I get this error Undefined function or variable 'dataX'.
so how can I access global variable from another .m file .. I'm new to Matlab
Best Answer