How to extract certain elements in matlab?

조회 수: 8 (최근 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 CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by