In the "Section 5 - Further Practice" of MATLAB Onramp, it is stated that, "Indices can be non-consecutive numbers. Try extracting the first, third, and sixth elements of density.". How to do it ?
조회 수: 6 (최근 30일)
이전 댓글 표시
In the "Section 5 - Further Practice" of MATLAB Onramp, it is stated that, "Indices can be non-consecutive numbers. Try extracting the first, third, and sixth elements of density.". How to do it ?
답변 (2개)
Lan Lou
2020년 9월 1일
You would use:
p=density([1 3 6],:)
or
p=density([1 3 6],end)
or
p=density([1 3 6],1)
댓글 수: 2
Jon Wagner
2020년 9월 18일
p=density([1 3 6],1) is correct. this gives the 1st 3rd and 6th element of column 1. since elements start at the top of the first column and move down, then to top of next column.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!