필터 지우기
필터 지우기

Related to function call

조회 수: 1 (최근 30일)
SHRUTHI k
SHRUTHI k 2015년 9월 14일
댓글: SHRUTHI k 2015년 9월 16일
Hello..I seek help in writing MATLAB code. I have written a code for some operation and I am getting the result. But I want to call this functio code in my main code. I know how to do function call but i don't know which syntax to use at the end of function code so that I can pass the final value to my main code. For example, I have a code for convolution "my_conv.m" without using builin conv(x,h). In my main code I used the syntax "my_conv(..,..);" for function call. Which syntax I need to use at the end of "my_conv" for passing the result to main code? Similar to this I am using many other functions for different operations. Thank you in advance.

채택된 답변

Guillaume
Guillaume 2015년 9월 14일
Have you looked at the help of function? It's all explained in there.
You declare which variable you want to return in the first line of your code:
function returnvalue = myfunc(someinput, someotherinput)
%output of function is returnvalue
%...
end
and you call it:
value = myfunc(a, b)
See the help linked above to see how to return more than one output from a function.
  댓글 수: 6
Walter Roberson
Walter Roberson 2015년 9월 16일
In .m files that start with "function", the rule is that you have to do it the same way every time: you can have functions that have matching "end", or you can have functions that do not have matching "end", but you cannot have both types in the same file. Having a matching "end" means something slightly different: it can be optimized more, but you cannot create new variables dynamically in the function by using eval() or related routines or by using load() without an output parameter.
SHRUTHI k
SHRUTHI k 2015년 9월 16일
OK...thank you..

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Performance and Memory에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by