how to write cell values to a file from matlab?
1 次查看(过去 30 天)
显示 更早的评论
hibelow here is to create header by feteching two files input.i got my output in 'out' variable.but i couldnt able to write in excel file with delimited.
ex:
#header_01= power,load,density,temp
#header_02=mean,std,max,min
needes output: power_mean power_std power_max and so on
each cell values must be saved in each cells in excel file..im stuck..help plz
nm = {'F:\header_01.txt','F:\header_02.txt'};
c1 = cell(1,2);
for jj = 1:2
f = fopen(nm{jj});
c = textscan(f,'%s');
fclose(f);
a1 = regexp(c{:},'\w*','match');
c1{jj} = cat(1,a1{:});
end
n = cellfun('length',c1);
[ii,jj] = ndgrid(1:n(2),1:n(1));
out = reshape(strcat(c1{1}(jj),{'_'},c1{2}(ii)),1,[]);if true
0 个评论
采纳的回答
Andrei Bobrov
2013-8-13
编辑:Andrei Bobrov
2013-8-13
xlswrite('NameYourXlsFile.xlsx',out,1,'A1')
ADD
f = fopen('F:\header_01.txt');
c = textscan(f,'%s');
fclose(f);
a1 = regexp(c{:},'\w*','match');
a1 = cat(1,a1{:});
a2 = {'mean' 'std' 'max' 'min'};
[ii,jj] = ndgrid(1:4,1:numel(a1));
out = reshape(strcat(a1(jj),{'_'},a2(ii)),1,[]);
xlswrite('NameYourXlsFile.xlsx',out,1,'A1')
3 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!