필터 지우기
필터 지우기

Cant write array to csv file - Please help

조회 수: 6 (최근 30일)
Siddhartha Sharma
Siddhartha Sharma 2018년 2월 7일
편집: Jan 2018년 2월 8일
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
Walter Roberson
Walter Roberson 2018년 2월 7일
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" ?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Octave에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by