hi i started the matlab onramp course and im stuck on this further practice question i wld appreciate if anyone cld help me or even give an hint
3 ビュー (過去 30 日間)
古いコメントを表示
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1757814/image.png)
3 件のコメント
Image Analyst
2024 年 8 月 22 日
That is not a question. It's just giving you information. For a demo of that, see the Answer below (scroll down) or show us the actual question.
採用された回答
Steven Lord
2024 年 8 月 22 日
As Image Analyst stated, it's an informational message not a question. Its intent is to let you know that the indices you use to index into an array in MATLAB need not refer to a contiguous section of the array. [They can, but they're not required to.]
x = (1:10).^2 % original array into which you want to index
contiguous = x([4 5 6]) % a section of x from the middle
You can skip elements.
skip = x(1:2:end) % get every other element of x
You can repeat elements.
repeated = x([3 5 5 7]) % 25 appears twice in the output
You can specify indices that aren't sorted.
unsorted = x([1 4 7 10 2:3:8 3 6 9]) % "shuffle" the elements
In this last section I used the "skip" pattern as part of generating the unsorted list. I could have done that slightly more compactly by using it for all three sections.
unsorted2 = x([1:3:10 2:3:8 3:3:9]) % "shuffle" the elements
その他の回答 (1 件)
Fangjun Jiang
2024 年 8 月 22 日
density=10:10:100
index=[1 3 6]
SelectedDensityValue=density(index)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!