Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

saving vectors to an excel file

Asked by John

John (view profile)

on 25 Mar 2012

Hello,

I am importing data from excel files, performing a process and saving data to a .mat file.

My question is, how could I save the vectors x and y2 to an excel file in a different folder but with the same name as the original excel file?

I've attempted it below but I'm not sure of the correct syntax?

Thank you

files = cellstr(ls('*.xls'));
for k = 1:length(files)
sch_cycle = xlsread(files{k}, 'Input_data');
nrows = size(sch_cycle,1)-1;
x = sch_cycle(:,1);
y = sch_cycle(:,2);
h=2;
N= size(sch_cycle,1);
r=ksr(x,y,h,N)
y1=r.f';
y = y(:);
y1 = y1(:);
y2 = [y(1:3); y1(4:end-3); y(end-2:end)];
sch_cycle = [x y2]; 
sch_grade=[0,0;nrows,0];
sch_grade=[0 0;nrows 0];
sch_key_on=[0 1; nrows 1];
[~,fn] = fileparts(files{k});
sch_metadata.name = fn;
sch_metadata.proprietary='public';
save([fn,'.mat'],'sch_cycle','sch_grade','sch_key_on','sch_metadata');
xlswrite(C:\Folder\files{k}, x y2)
end

0 Comments

John

John (view profile)

Tags

Products

No products are associated with this question.

1 Answer

Answer by Geoff

Geoff (view profile)

on 25 Mar 2012

To build the filename use:

['C:\Folder\' files{k}]

0 Comments

Geoff

Geoff (view profile)

Contact us