MATLAB: Import some cellls data from a program into another one.

cell arrayssave

Hi all
I've written a program named "a.1" which its output is some cells. Hence this program is too long and time-consuming in running, I have to use just the outputs as the input of another program, which named "a.2" .
For example: following loops and corresponding " ropt_final_matrix{t}(ss,qq)" are the outputs of program a.1.
for t=1:T
for ss=1:ns
for qq=1:nq
ropt_final_matrix{t}(ss,qq)=ropt_final{t,ss}(qq,1);
end
end
end
I want to use just " ropt_final_matrix{t}(ss,qq)" as the input of program a.2, without frequently running of program a.1.
1.How can I do it?
2.How can I export, save and import some outputs in the form of cells?
Could you please clearly guide me?
Thanks,

Best Answer

save('ropt_final_matrix.mat', ropt_final_matrix)
and in a2,
indata = load('ropt_final_matrix.mat');
ropt_final_matrix = indata.ropt_final_matrix;
By the way, part of the reason your program is so slow is that you are not pre-allocating memory.
ropt_final_matrix = cell(T,1); %NEW

for t=1:T
ropt_final_matrix{t} = zeros(ns, nq); %NEW
for ss=1:ns
for qq=1:nq
ropt_final_matrix{t}(ss,qq)=ropt_final{t,ss}(qq,1);
end
end
end
Related Question