How to extract certain elements in matlab?

5 ビュー (過去 30 日間)
Raja R
Raja R 2016 年 1 月 9 日
コメント済み: Image Analyst 2016 年 2 月 29 日
if a=[1 2 3 4 5 6 7 8 9 10]; then i need answer as b=[1 2 3 4 5] and c-[6 7 8 9 10]

回答 (1 件)

Image Analyst
Image Analyst 2016 年 1 月 9 日
To extract b and c from a, do this:
a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
b = a(1 : 5);
c = a(6 : 10);
If 10 is the very last element of a, then you can use end instead of 10:
c = a(6:end);
All of this very basic stuff such as indexing should be covered in the "Getting started" documentation.
  1 件のコメント
Image Analyst
Image Analyst 2016 年 2 月 29 日
Raja, did that answer your question?

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

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by