How can I get a vector out of a matrix?
12 ビュー (過去 30 日間)
古いコメントを表示
Given a two dimension matrix, if I want to extract 3 elements with subsript (1,2) (2,4) (3,6) to form a vector, how I can I achieve that without using a double loop? Because if I just use M(1:3,2:2:6), the result will also be a matrix. Can someone give me a simple solution?
2 件のコメント
KALYAN ACHARJYA
2017 年 9 月 9 日
編集済み: KALYAN ACHARJYA
2017 年 9 月 9 日
First convert Matrix to vector
%
vector=matrix(:);
%Do the Operation
result=[vector(1,2),vector(2,4),vector(1,2),vector(3,6)]
%
回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!