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

조회 수: 1(최근 30일)
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;
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?


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();


Community Treasure Hunt

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

Start Hunting!

Translated by