Output in a export data function

2 次查看(过去 30 天)
I was trying to create a function to write matrices to excell files. Does anyone know what the right output should be? What I try down here obviously doesn't work because the outputs are excell files, not mat files.
function[gait,stair up,stair down] = exportdata(MeanGait,StdGait,MeanStairUp,StdStairUp,MeanStairDown,StdStairDown)
xlswrite('gait',names2,'B1:G1');
xlswrite('gait',MeanGait,'B2:G101');
xlswrite('gait',StdGait,'Feuil2','B2:G101');
xlswrite('gait',names2,'Feuil2','B1:G1');
xlswrite('stair up',names2,'B1:G1');
xlswrite('stair up',MeanStairUp,'B2:G101');
xlswrite('stair up',StdStairUp,'Feuil2','B2:G101');
xlswrite('stair up',names2,'Feuil2','B1:G1');
xlswrite('stair down',names2,'B1:G1');
xlswrite('stair down',MeanStairDown,'B2:G101');
xlswrite('stair down',StdStairDown,'Feuil2','B2:G101');
xlswrite('stair down',names2,'Feuil2','B1:G1');
end

回答(1 个)

Walter Roberson
Walter Roberson 2015-12-27
? You do not have any input named "names2" and you do not create a variable by that name.
[gait,stair up,stair down] is not valid syntax on the left side of "=" in a "function" declaration. It is not permitted in MATLAB to have variables with spaces in the name.
I notice those happen to be the same as the strings you pass as file names for xlswrite. Are you attempting to return the names of the files, or are you attempting to somehow return the files themselves (perhaps in binary form) ?
For xlswrite() it is better to supply the file extension, such as
gaitfile = 'gait.xlsx';
xlswrite(gaitfile, .....)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by