Help creating a function library

조회 수: 5 (최근 30일)
Kevin Edlebeck
Kevin Edlebeck 2018년 2월 6일
편집: Jan 2018년 2월 6일
I've been doing an assignment incorrectly the past few days and need help:
I need to create a library of functions that I can add to new scripts in MATLAB. They are simple equations that rely on 3 inputs. So I need to be able to type E(#,#,#) in the script and have it give me a result based on a function I have defined as E. I have figured out how to create a function but I do not understand how to use it. I've check to documentation but mine isnt working.
  댓글 수: 1
Jan
Jan 2018년 2월 6일
"mine isnt working" would be clear, if you post your code, show how you call it and show us the error message. It is not efficient if the readers guess, what you have written, how you call it and what you observe.

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

답변 (1개)

Jan
Jan 2018년 2월 6일
편집: Jan 2018년 2월 6일
Store this as an M-file:
function Result = E(In1, In2, In3)
Result = In1 * In2 + In3;
end
Now call this by:
Result = E(1, 2, 3)

카테고리

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