Corresponding vector values to array values

14 ビュー (過去 30 日間)
giorgos kivides
giorgos kivides 2020 年 1 月 23 日
コメント済み: giorgos kivides 2020 年 1 月 23 日
I have an array 51 by 51 and I have 6 vectors where the vector elements are the dimensions of the array. How i correspoding the vector values to the array values?
I attach an excel file with the array and the vectors.
  4 件のコメント
Walter Roberson
Walter Roberson 2020 年 1 月 23 日
Your matrix is 51 x 51, so it is not immediately clear what matrix(1-31),(31-11) might mean. Are you looking for matrix(1,31) then matrix(31,11) then matrix(11,40) and so on? So a path through the matrix?
giorgos kivides
giorgos kivides 2020 年 1 月 23 日
for example. when it reads the numbers 1-47 of vector, it will go to the array in row 1 and column 47 and read the number.

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

回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 1 月 23 日
Vector = [1 31 11 40 34 46 19 25 24 0 0];
nodes = Vector(Vector ~= 0);
total = sum(Matrix(sub2ind(size(Matrix), nodes(1:end-1), nodes(2:end))));
  1 件のコメント
giorgos kivides
giorgos kivides 2020 年 1 月 23 日
Thanks a lot..

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

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by