how to write cell values to a file from matlab?

1 view (last 30 days)
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

Accepted Answer

Andrei Bobrov
Andrei Bobrov on 13 Aug 2013
Edited: Andrei Bobrov on 13 Aug 2013
use function xlswrite:
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 Comments
sandy
sandy on 14 Aug 2013
Thanks..it works...< https://www.mathworks.in/accesslogin/index_fe.do?uri=http://www.mathworks.com/matlabcentral/answers/contributors/4344472-santhosh-kumar/questions>...can u see this link for another error

Sign in to comment.

More Answers (0)

Categories

Find more on Instrument Control Toolbox Supported Hardware in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!