size() function returns wrong size

조회 수: 16 (최근 30일)
danielle sisserman
danielle sisserman 2020년 11월 7일
댓글: danielle sisserman 2020년 11월 7일
i have the following line of code:
s = size(k_distances)
k_distances is a 1x1 matrix:
but the size function returns a size of 1x2:
and then:
k_labels = zeros(s);
returns a 3x1 matrix that not all zeros!!
any idea what is happening?
thank you
  댓글 수: 4
danielle sisserman
danielle sisserman 2020년 11월 7일
John, I posted both code and pictures. thank you :)
danielle sisserman
danielle sisserman 2020년 11월 7일
Vasishta, turns out my break point was further along the script and I manged to change k_labels much after the assignment. my bad.

댓글을 달려면 로그인하십시오.

채택된 답변

Mario Malic
Mario Malic 2020년 11월 7일
k_labels should return 1x1 array with value of zero.
Did you clear workspace from previous runs?
From the documentation on function size
sz = size(A) returns a row vector whose elements are the lengths of the corresponding dimensions of A. For example, if A is a 3-by-4 matrix, then size(A) returns the vector [3 4].
If A is a table or timetable, then size(A) returns a two-element row vector consisting of the number of rows and the number of table variables.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Identification에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by