fprintf length of vector
조회 수: 4 (최근 30일)
이전 댓글 표시
how do i print the length of a vector?? so i have a vector V = [4,9,-3,12,0,-9,15,17,25,-6,4,10,-2,15] and i got its length by L = length (V) now how do i print the length?
댓글 수: 0
답변 (1개)
Adam Danz
2019년 4월 17일
편집: Adam Danz
2019년 4월 23일
fprintf('Length of vector is %d\n', length(V))
The " %d " specifies that the number to be printed is an integer which should always be the output of length().
The " \n " specifies that a new line should be started after this text.
댓글 수: 1
Guillaume
2019년 4월 23일
Note: another option that may be more intuitive for beginners
disp("Length of vector is " + length(V))
I'd recommend using numel rather than length. Many people misuse length.
참고 항목
카테고리
Help Center 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!