필터 지우기
필터 지우기

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에서 Whos에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by