Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

how to use "if" statement properly?

조회 수: 1 (최근 30일)
john borsellino
john borsellino 2013년 6월 4일
마감: MATLAB Answer Bot 2021년 8월 20일
i am performing an element -wise operation on 2 columns, A & B.
1. z=B./A
if z is less than 1 then reverse operation for that element and multiply by -1
2. if z<1 3. (A./B)*-1 end but it does not work. this should be simple. can someone help please thanks jb

답변 (1개)

Iman Ansari
Iman Ansari 2013년 6월 4일
A=rand(10,1);
B=rand(10,1);
z=B./A;
z(z<1)=-1./z(z<1)
  댓글 수: 1
john borsellino
john borsellino 2013년 6월 4일
thankyou

Community Treasure Hunt

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

Start Hunting!

Translated by