필터 지우기
필터 지우기

convert code from excel to matlab

조회 수: 2 (최근 30일)
Brian Kirkland
Brian Kirkland 2021년 12월 11일
편집: Rena Berman 2021년 12월 13일
How do I convert my excel code to matlab? The excel code below contains two "IF" statements and one "AND" statement.
x = IF(AND(2*abs(d)>3*abs(l-n), 2*abs(d)>3*abs(r-n)), 2*abs(d), IF(3*abs(l-n)>3*abs(r-n), 3*abs(l-n), 3*abs(r-n)))
  댓글 수: 1
Rena Berman
Rena Berman 2021년 12월 13일

(Answers Dev) Restored edit

댓글을 달려면 로그인하십시오.

답변 (1개)

Chunru
Chunru 2021년 12월 11일
% x = IF(AND(2*abs(d)>3*abs(l-n), 2*abs(d)>3*abs(r-n)), 2*abs(d), IF(3*abs(l-n)>3*abs(r-n), 3*abs(l-n), 3*abs(r-n)))
if (2*abs(d)>3*abs(l-n)) & (2*abs(d)>3*abs(r-n))
x = 2*abs(d);
elseif (3*abs(l-n)>3*abs(r-n)) & (3*abs(l-n))
x = 3*abs(r-n)));
end
  댓글 수: 1
Walter Roberson
Walter Roberson 2021년 12월 11일
Note that the above will only work if d and l and n and r are all scalar values. If arrays are being processed then different code would be needed.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by