I have a multidimensional matrix M and a vector V of indeces that i use in this way:
M(V(1),V(2),V(3),...)
Is there a better way to do that? If V has 100 elements is not a good idea write the code in this way.
Moreover if i have 2 vector of indeces V1 and V2, is there a better way that combine them in a single vector
V=[V1 V2];
and use it as previously.
And finally: if V is not a vector but a Matrix and i would like use it like
M(V(1,1),V(1,2),...,V(2,1),V(2,2),...,...)
can i write something to avoid me to reshape V in a vector form?
Thank you in advance.

 採用された回答

madhan ravi
madhan ravi 2019 年 1 月 4 日

0 投票

V=num2cell(V);
matrix(V{:})

2 件のコメント

Federico Spada
Federico Spada 2019 年 1 月 4 日
I don't know why it works, but it does. Thank you!

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

その他の回答 (1 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品

リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by