Preventing unwanted variables being saved in .mat file

조회 수: 3 (최근 30일)
John
John 2012년 3월 16일
Hi there,
I am using the code below to create a .mat file.
In the .mat file it is saving
  1. fn
  2. k
  3. nrows
  4. sch_cycle
  5. sch_grade
  6. sch_key_on
  7. sch_metadata
  8. x
How could I make it only save these only?
  1. sch_cycle
  2. sch_grade
  3. sch_key_on
  4. sch_metadata
x = cellstr(ls('*.xls'));
for k = 1:length(x)
sch_cycle=xlsread('C:\Autonomie practice\cycle.xls','Input_data');
nrows = size(sch_cycle,1);
sch_grade=[0,0;nrows,0];
nrows = size(sch_cycle,1);
sch_grade=[0 0;nrows 0];
sch_key_on=[0 1; nrows 1];
[~,fn] = fileparts(x{k});
sch_metadata.name = fn;
sch_metadata.proprietary='public';
save([fn,'.mat']);
end
Thank you

채택된 답변

Jonathan Sullivan
Jonathan Sullivan 2012년 3월 16일
save([fn,'.mat'],'sch_cycle','sch_grade',sch_key_on','sch_metadata');
help save
doc save
  댓글 수: 3
Jan
Jan 2012년 3월 16일
The leading quote before sch_key_on is missing.
John
John 2012년 3월 16일
Thanks, I should of seen that!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by