how to write cell values to a file from matlab?

1 visualización (últimos 30 días)
sandy
sandy el 13 de Ag. de 2013
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

Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 13 de Ag. de 2013
Editada: Andrei Bobrov el 13 de Ag. de 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 comentarios
Andrei Bobrov
Andrei Bobrov el 13 de Ag. de 2013
see ADD part in my answer
sandy
sandy el 14 de Ag. de 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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by