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