problem indexing a matrix from arrays
1 回表示 (過去 30 日間)
古いコメントを表示
I want matlab to return all the elements of p2 at rows r columns c, I tried p2(r,c), but that doesn't give me the right answer.
p2 =
0.1500 0.1500
0.4804 0.4804
0.5098 0.5098
0.0498 0.0498
1.1008 1.1008
1.0920 1.0920
2.0219 2.0219
1.1342 1.1342
2.9643 2.9643
3.8808 3.8808
3.8487 3.8487
4.9765 4.9765
8.3789 8.3789
7.7730 7.7730
r =
3
6
7
9
10
12
3
6
7
9
10
12
c =
1
1
1
1
1
1
2
2
2
2
2
2
>> p2(r,c)
ans =
Columns 1 through 5
0.5098 0.5098 0.5098 0.5098 0.5098
1.0920 1.0920 1.0920 1.0920 1.0920
2.0219 2.0219 2.0219 2.0219 2.0219
2.9643 2.9643 2.9643 2.9643 2.9643
3.8808 3.8808 3.8808 3.8808 3.8808
4.9765 4.9765 4.9765 4.9765 4.9765
0.5098 0.5098 0.5098 0.5098 0.5098
1.0920 1.0920 1.0920 1.0920 1.0920
2.0219 2.0219 2.0219 2.0219 2.0219
2.9643 2.9643 2.9643 2.9643 2.9643
3.8808 3.8808 3.8808 3.8808 3.8808
4.9765 4.9765 4.9765 4.9765 4.9765
Columns 6 through 10
0.5098 0.5098 0.5098 0.5098 0.5098
1.0920 1.0920 1.0920 1.0920 1.0920
2.0219 2.0219 2.0219 2.0219 2.0219
2.9643 2.9643 2.9643 2.9643 2.9643
3.8808 3.8808 3.8808 3.8808 3.8808
4.9765 4.9765 4.9765 4.9765 4.9765
0.5098 0.5098 0.5098 0.5098 0.5098
1.0920 1.0920 1.0920 1.0920 1.0920
2.0219 2.0219 2.0219 2.0219 2.0219
2.9643 2.9643 2.9643 2.9643 2.9643
3.8808 3.8808 3.8808 3.8808 3.8808
4.9765 4.9765 4.9765 4.9765 4.9765
Columns 11 through 12
0.5098 0.5098
1.0920 1.0920
2.0219 2.0219
2.9643 2.9643
3.8808 3.8808
4.9765 4.9765
0.5098 0.5098
1.0920 1.0920
2.0219 2.0219
2.9643 2.9643
3.8808 3.8808
4.9765 4.9765
I should be getting this:
0.5098
1.092
2.0219
2.9643
3.8808
4.9765
0.5098
1.092
2.0219
2.9643
3.8808
4.9765
0 件のコメント
採用された回答
その他の回答 (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!