Error: Attempt to add (variable) to a static workspace,

34 views (last 30 days)
My function
function Densite
load x;
load h
if ...........................
.................
elseif ........................
........................
end
end
error
Error using ===> load
Attempt to add "x" to static workspace
Errr in ===> Densite
load x;

Accepted Answer

Max Murphy
Max Murphy on 31 Dec 2019
Try
function Densite
% load x;
% load h
in = load('x.mat','x'); % If these were together in one file, like 'data.mat'
x = in.x; % then you could load both at once
in = load('h.mat','h');
h = in.h;
if ...........................
.................
elseif ........................
........................
end
end
error
Error using ===> load
Attempt to add "x" to static workspace
Errr in ===> Densite
load x;

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!