- ‘The relational operators are <, >, <=, >=, ==, and ~=. Relational operators perform element-by-element comparisons between two arrays.’
Create a new vector with the elements of another vector
조회 수: 9 (최근 30일)
이전 댓글 표시
I have 2 vectors
a=[5 1 9 7 0 -5 1 -2]
b=[2 8 1 6 -8 -3 4 1] I need to create a vector c, which is made up of elements of b that are greater than a.
My attempt:
c=b(b>a)
c= 8 4 1
I don't know if I understand the question or it is that easy. Please help me!
댓글 수: 0
채택된 답변
Star Strider
2014년 10월 22일
It could be that easy, depending on how the question was phrased and what it wants you to do. From the documentation on Relational Operators < > <= >= == ~=
(I got c = [8 -3 4 1] so I assume you left out -3.)
댓글 수: 0
추가 답변 (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!