how to select specific values in a matrix

603 ビュー (過去 30 日間)
Shani
Shani 2013 年 11 月 18 日
コメント済み: Image Analyst 2013 年 11 月 23 日
Hi I will give an example, I have a 10X10 matrix, I want to select the 4th value in the first row, the 7th value in the 4th row and value 5 onwards on the 3rd row, and selecting multiple values from different rows. If anyone can help me. Thanks
  1 件のコメント
Image Analyst
Image Analyst 2013 年 11 月 23 日
Here is what Shani asked, so that it will still be here when she deletes this question:
Hi I will give an example, I have a 10X10 matrix, I want to select the 4th value in the first row, the 7th value in the 4th row and value 5 onwards on the 3rd row, and selecting multiple values from different rows. If anyone can help me. Thanks

サインインしてコメントする。

採用された回答

Doug Hull
Doug Hull 2013 年 11 月 18 日
>> a = magic(10)
a =
92 99 1 8 15 67 74 51 58 40
98 80 7 14 16 73 55 57 64 41
4 81 88 20 22 54 56 63 70 47
85 87 19 21 3 60 62 69 71 28
86 93 25 2 9 61 68 75 52 34
17 24 76 83 90 42 49 26 33 65
23 5 82 89 91 48 30 32 39 66
79 6 13 95 97 29 31 38 45 72
10 12 94 96 78 35 37 44 46 53
11 18 100 77 84 36 43 50 27 59
>> a(1,4)
ans =
8
>> a(4,7)
ans =
62
>> a(3,5:end)
ans =
22 54 56 63 70 47
  2 件のコメント
BSantos
BSantos 2013 年 11 月 18 日
If I understand correctly, that's because your matrix is a 10x10, so only 10 values per row/column.
BSantos
BSantos 2013 年 11 月 18 日
Ah no problem.
Also, that error message means that your matrix has 25 rows and 3 columns. So, it's not possible to access the value on W2(1,24).

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by