필터 지우기
필터 지우기

import some cellls data from a program into another one.

조회 수: 2 (최근 30일)
som
som 2012년 1월 19일
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,
  댓글 수: 1
Walter Roberson
Walter Roberson 2012년 1월 19일
Please do not use your initials for the Tag. You can find your own posts easily using the My Questions feature. The Tag is to allow categorization of related posts.

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2012년 1월 19일
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
  댓글 수: 2
som
som 2012년 1월 19일
Thanks for your guidance about tags.
Walter Roberson
Walter Roberson 2012년 1월 20일
Your loop "for qq" can be removed and replaced with
ropt_final_matrix{t}(ss,1:nq) = ropt_final{t,ss}(1:nq,1);
Also if nq is certain to be the exactly the same as the number of rows in all ropt_final{t,ss} then the 1:nq can be changed to : with no explicit range.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Software Development Tools에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by