I'm working on a matlab code where I have a lot of variables that need to be preallocated (each variable is 8760x1 double). The values are generated in a for loop:
a=zeros(8760,1);
b=zeros(8760,1);
(...)
for i=1:8760
a(i)=[some code];
b(i)=[some code];
(...)
end
However, seeing that I have a lot of these variables, I want to preallocate the parameters in another file (more clean).
preallocate.m
a=zeros(8760,1);
b=zeros(8760,1);
...
main.m
preallocate
for i=1:8760
a(i)=[some code];
b(i)=[some code];
(...)
end
Will preallocating in another matlab file be as efficient as doing it in the same file as the executing file? Other suggestions?