Cant write array to csv file - Please help
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Code ---
function result = createArrays(nArrays, arraySize)
result = cell(1, nArrays);
for i = 1 : nArrays
result{i} = zeros(arraySize);
end
end
To use it:
myArray = createArrays(44, [2464,1]);
for i = 1:44
if i==1
j=1;
elseif i>1
j=CountryVar(i-1)+1;
end
for ii = 1:2464
for jj = j: CountryVar(i)
if jj<= CountryVar(i)
myArray(i) = sum(ImportsBreakdownMatrix(:,j:CountryVar(i)));
end
end
end
end
CountryVar = [56:56:2464];
and ImportsBreakdownMatrix is just 2464, 2464 matrix with numbers
The calculations work but I can write myArray in csv file.
CSV2CELL, dlmwrite have not helped.
I am trying to separate a 2464,2464 matrix into 44 matrices of 2464,1 summing 56 columns at a time which is why I used arrays.
Any help will be appreciated..
1 comentario
Walter Roberson
el 7 de Feb. de 2018
You have a cell array with the entries being numeric row vectors (not the column vectors you initialize.) The export routines will refuse to export that in one piece to a single csv file because csv files have no ability to store groups of numbers in one csv location. Each location in a csv must be either empty, or a numeric scalar, or a string (possibly double-quoted).
Perhaps you should loop writing one cell per file ? Or perhaps you should use an excel file and create different "sheets" ?
Respuestas (0)
Ver también
Categorías
Más información sobre Octave 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!