compare elements of a 2x1 column vector

조회 수: 1 (최근 30일)
Jetty Rakesh Aditya
Jetty Rakesh Aditya 2020년 10월 24일
답변: Ameer Hamza 2020년 10월 24일
i have a cell c that has 2x1 column vectors as elements
c {1} = [1;0](say v1)
c{2} = [2;3](say v2)
now i want to compare the
elements of the vectors and store 1 if v(1) > v(2) and store 0 if v(1)<v(2)
how can i achieve this?

답변 (1개)

Ameer Hamza
Ameer Hamza 2020년 10월 24일
You can directly make the comparison using the cell array
c{1} = [1;0];
c{2} = [2;3];
comp_result = c{1}(1) > c{2}(2);

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by