Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
Laurentiu Galan
Laurentiu Galan le 14 Nov 2011
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,

Réponses (1)

Fangjun Jiang
Fangjun Jiang le 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();

Catégories

En savoir plus sur Data Types dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by