フィルターのクリア

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 Center および File ExchangePerformance and Memory についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by