Why am I getting this horzcat error? The dimensions are the same(??)
2 views (last 30 days)
Show older comments
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,
0 Comments
Answers (1)
Fangjun Jiang
on 14 Nov 2011
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();
0 Comments
See Also
Categories
Find more on Environment and Settings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!