learning to create functions in matlab(R2019a) but every time i try to do so , The value assigned might be un used (used a)create the file in code file, Am a beginner
조회 수: 1 (최근 30일)
이전 댓글 표시
function myRand
a=1+rand(3,4)*9
end
thats it..am a beginner learning to create functions
댓글 수: 0
답변 (1개)
Bjorn Gustavsson
2021년 12월 8일
편집: Bjorn Gustavsson
2021년 12월 8일
Ok, here's what you're missing in this example:
function a = myRand
a=1+rand(3,4)*9;
end
Now your function has an output-variable, a, that the function will return when called. You can also have multiple output-variables:
function [a,b] myRand
a=1+rand(3,4)*9;
b = sin(a);
end
For the cases where that is prefereable.
Since you are a beginner you might consider looking over the "on-ramp" material on the site: on-ramp.
HTH
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Mapping Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!