Effacer les filtres
Effacer les filtres

Cant write array to csv file - Please help

6 vues (au cours des 30 derniers jours)
Siddhartha Sharma
Siddhartha Sharma le 7 Fév 2018
Modifié(e) : Jan le 8 Fév 2018
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 commentaire
Walter Roberson
Walter Roberson le 7 Fév 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" ?

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Octave dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by