Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
Date conversion program error
조회 수: 1 (최근 30일)
이전 댓글 표시
I have a program that finds the time column in a data sheet (in unix time) and takes each time value and makes a new excel document and converts it into the hour.
Here's the code I made for it: fileid=['sitedata.csv']; [data, text] = xlsread(fileid); col = strcmpi(text(1,:),'Time'); A = data(:,col); for i = 1:length(A) X = datenum([1970 1 1 0 0 A(i)]); hour = datestr(X, 'HH'); A(i) = hour; end
When I run it the error I get is: ??? In an assignment A(I) = B, the number of elements in B and I must be the same.
Error in ==> time at 28
A(i) = hour;
Any ideas how to fix this? Thank you!
댓글 수: 0
답변 (1개)
Fangjun Jiang
2011년 7월 5일
In your code, "A" is a double array, "hour" is a char array. If you change A(i)=hour to B{i}=hour, it will work. But it's better to pre-allocate B as a cell array right before the for-loop B=cell(size(A));
댓글 수: 2
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!