フィルターのクリア

index array to access the value in matrix

1 回表示 (過去 30 日間)
AniCnx
AniCnx 2019 年 11 月 14 日
コメント済み: AniCnx 2019 年 11 月 15 日
Hi all, I have 3 matrixes as matrix IM (200x200); X(400x400); Y(400x400). As matrix x and y is indexing the matrix IM. How can I use x and y matrix to access the value of matrix IM withouf for loop.
  2 件のコメント
Shubham Gupta
Shubham Gupta 2019 年 11 月 14 日
Can you please share mat file or put a small example to show what is stored in X,Y & IM?
Small example can be like X&Y of size 4x4 & IM being 2x2, then you can show desired output for this example.
AniCnx
AniCnx 2019 年 11 月 14 日
IM=4.08809852121212 4.29250344727273 4.39470591030303 4.44580714181818 4.44580714181818 4.54800960484849 4.65021206787879 4.75241453090909 4.80351576242424 4.95681945696970
4.39470591030303 4.44580714181818 4.49690837333333 4.54800960484849 4.59911083636364 4.65021206787879 4.75241453090909 4.80351576242424 4.85461699393939 4.95681945696970
4.34360467878788 4.44580714181818 4.49690837333333 4.59911083636364 4.59911083636364 4.65021206787879 4.75241453090909 4.80351576242424 4.80351576242424 4.90571822545455
4.34360467878788 4.39470591030303 4.49690837333333 4.59911083636364 4.59911083636364 4.70131329939394 4.75241453090909 4.75241453090909 4.75241453090909 4.85461699393939
4.29250344727273 4.39470591030303 4.44580714181818 4.54800960484849 4.59911083636364 4.70131329939394 4.70131329939394 4.75241453090909 4.80351576242424 4.80351576242424
4.29250344727273 4.34360467878788 4.44580714181818 4.54800960484849 4.59911083636364 4.70131329939394 4.75241453090909 4.75241453090909 4.80351576242424 4.80351576242424
4.29250344727273 4.34360467878788 4.39470591030303 4.49690837333333 4.59911083636364 4.70131329939394 4.75241453090909 4.80351576242424 4.80351576242424 4.80351576242424
4.29250344727273 4.34360467878788 4.39470591030303 4.49690837333333 4.59911083636364 4.75241453090909 4.75241453090909 4.75241453090909 4.80351576242424 4.80351576242424
4.34360467878788 4.34360467878788 4.39470591030303 4.49690837333333 4.59911083636364 4.70131329939394 4.80351576242424 4.80351576242424 4.80351576242424 4.85461699393939
4.44580714181818 4.44580714181818 4.39470591030303 4.49690837333333 4.59911083636364 4.70131329939394 4.75241453090909 4.75241453090909 4.80351576242424 4.80351576242424
x=1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
y=1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10

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

採用された回答

Shubham Gupta
Shubham Gupta 2019 年 11 月 14 日
Step1 - Convert the subscript to indeces using x & y(Hint: sub2ind)
Step2 - Calculate values of IM for calculated indeces
Step3 - Reshape it to match the dimesion with x or y (Hint: reshape)
Something like this:
output = reshape(IM(sub2ind(size(IM),x(:),y(:))),size(x,1),size(x,2));
Let me know if you have doubt
  1 件のコメント
AniCnx
AniCnx 2019 年 11 月 15 日
Thank you very much. it works very well.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by