How to display a single element from a matrix?

154 次查看(过去 30 天)
Hi, I was wondering how I would be able to display a singular element from a given matrix. If I were to have a random integer matrix
x = randi (20,20)
x = 20×20
11 6 2 1 3 12 17 11 4 4 5 15 2 9 4 1 6 18 18 8 5 18 11 17 12 10 7 20 15 5 17 10 10 1 5 4 10 1 15 1 16 13 7 19 20 6 1 20 20 13 11 15 1 8 10 13 1 17 7 3 3 6 9 15 18 4 18 9 3 8 15 9 11 17 8 2 9 10 19 2 4 7 8 6 10 17 5 9 18 16 11 7 8 8 1 18 14 8 5 17 5 10 11 10 16 4 15 13 16 13 8 20 10 3 9 18 1 20 13 5 6 6 8 18 15 7 2 1 8 20 4 4 6 10 19 1 7 20 6 2 15 8 6 7 9 17 20 20 17 2 3 14 13 18 17 8 20 9 2 15 11 1 3 18 1 20 14 9 20 6 13 13 16 10 6 7 4 2 11 15 11 9 5 16 5 6 4 8 9 12 18 5 16 20 18 12 7 19 15 17
how would I go about selecting or highlighting the given value from a random row/column combination (say I want to know what vlaue is at [5, 7])? Thanks in advance for the advice.
  1 个评论
Stephen23
Stephen23 2022-9-14
编辑:Stephen23 2022-9-14
x = randi(20,20,20)
x = 20×20
8 16 8 7 20 10 2 1 20 4 1 18 7 20 11 12 10 3 9 14 6 11 20 10 13 15 6 3 16 11 6 11 5 20 11 17 18 7 17 1 12 7 5 16 16 12 16 14 4 13 3 14 13 18 9 4 9 1 1 18 8 6 18 5 9 17 10 4 3 1 5 4 12 7 20 20 9 14 20 2 12 14 5 14 9 15 15 16 18 12 1 14 7 1 5 4 8 7 15 9 19 2 5 5 1 7 10 10 17 19 4 14 19 1 8 9 15 1 16 13 6 9 16 16 4 11 5 14 2 8 15 19 3 5 12 5 9 10 7 7 8 15 13 13 3 10 2 5 16 1 3 14 20 1 4 13 16 6 1 5 10 17 12 13 18 13 20 13 11 17 14 16 2 15 8 10 9 17 14 6 14 3 1 18 17 11 19 13 7 17 3 15 5 10 2 2 18 18 16 15
x(5,7)
ans = 15

请先登录,再进行评论。

回答(1 个)

Jan
Jan 2022-9-15
Indexing is a fundamental Matlab method. To learn the basics asking in the forum is less efficient than using the tutorials:

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by