Why am I getting this horzcat error? The dimensions are the same(??)

조회 수: 2 (최근 30일)
Laurentiu Galan
Laurentiu Galan 2011년 11월 14일
Here is my code:
[numericalData, textData] = xlsread('c:\Users\Laurentiu Galan\Desktop\tickoutput2\A.csv');
newmat=flipud(numericalData(1:end, 6));
A = flipud(textData(2:end, 1));
B = size(newmat);
RetMat = zeros(B(1,1),1);
for j=2:B(1,1);
Retmat(j,1) = (newmat(j,1)/newmat(j-1,1))-1;
end;
size(A)
size(newmat)
size(Retmat)
OutputData = horzcat(newmat, Retmat);
The sizes for A, newmat and retmat are all the same [2983 x 1]. Why do I get an error saying: "??? Error using ==> horzcat CAT arguments dimensions are not consistent". A is all text, does this make a difference?
Thanks,

답변 (1개)

Fangjun Jiang
Fangjun Jiang 2011년 11월 14일
A is text data. It's likely in cell array. newmat is numerical data. It's likely double array.
You can't concatenate them directly.
Use the third output argument of xlsread to treat them all as cell array.
[Num, Txt, Raw]=xlsread();

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by