I want to be able to save variables to disk sometimes. And I want to save it in a subfolder called '_WorkData'.
The bellow code works fine as a stand alone code
OutputName = 'my favorite file';
save(['_WorkData/' OutputName '.mat'], 'foobar');
However as a function it cant find the variable Variable 'foobar' not found.
function noDataReturn = saveFileDisk(name,variable)
save(['_WorkData/' name '.mat'], variable);
noDataReturn = 'file saved';
end
I can see why this happens but I'm not familair enough with matlab code to understand how to correct it.
Any help would be appreciated!