basics - a more compact way to do this...?

조회 수: 1 (최근 30일)
Neuron
Neuron 2011년 11월 14일
I have a size(x) function that gives answer: 1 23 (x is a vector with 23 points). I can take the second value like this
k=size(x)
k(2)
Is there a more immediate way to do this? in a single command, something like.. size(x)(2) ?

채택된 답변

Sven
Sven 2011년 11월 14일
The simplest method is:
k = size(x, 2)
The second argument of the "size" method is the dimension in which to query - in your case the 2nd dimension
  댓글 수: 1
Fangjun Jiang
Fangjun Jiang 2011년 11월 14일
Sometimes you can use length() or numel().

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by