Error in length of matrix

3 次查看(过去 30 天)
Yasmin Tamimi
Yasmin Tamimi 2012-7-23
Hey Everyone,
I have 2 txt file the first one is A with size (70x15) and the other one B with size (12x15). I want to make them both of the same size without cutting data, so I padded the other one with nans.
B = importdata('definite.txt'); %% when I read the matrix and when I type whos I get the size of (12x15) BUT when I write length(B) I get 15!!!
pad= nan((length(A) - length(B)),15); Data_definite = [A;pad];
Som I couldn't figure what is wrong!! I tried doing so with other txt files and it worked fine except with this one!!

采纳的回答

Jan
Jan 2012-7-23
编辑:Jan 2012-7-23
I do not understand, what the problem is. I guess, that you expect length() to reply the length of the first dimension. But as doc length explains, it replies the length of the longest dimension or 0, if the array is empty.
X = rand(12, 15);
length(X)
size(X)
size(X, 1) % <== I think you want this

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by