passing output between functions

2 次查看(过去 30 天)
Silibelo Kamwi
Silibelo Kamwi 2011-8-2
Hi everyone, can anyone help or point me in the right direction.how do i pass the output from one function to another.
thanks

回答(2 个)

Dustin
Dustin 2011-8-2
Hi Silbelo,
Is there some specific type of functionality you are trying to achieve? If not, then the same format as in many other programming languages should suffice:
output1 = func1(input1);
output2 = func2(output1);
  2 个评论
Silibelo Kamwi
Silibelo Kamwi 2011-8-2
Hi Dustin, i'm trying to maximise a likelihood function which involves some double integral over a product of two functions where one function's parameters are known and the other one is a log function times an integral, i have a code where i'am doing the integration of one function first and the result i need to mutiply with the second function and take the final integral of.i have at the moment used function handles which seems to work except the results are not good:
output1=function1(input1)
output2=function(input2)
output1=@function1
return;
Thanks
Dustin
Dustin 2011-8-6
Can you post a simple example here to clearly demonstrate the problem? Otherwise, in your case, I don't see why output2 = function(function1(input1)) would not work.

请先登录,再进行评论。


Jan
Jan 2011-8-2
If I understand the question correctly:
function [A] = func1(B)
A = sin(B);
function [C] = func2(D)
C = func1(B);
Does this help to understand how arguments are forwarded??
  2 个评论
Silibelo Kamwi
Silibelo Kamwi 2011-8-2
Hi Jan, i'm trying to maximise a likelihood function which involves some double integral over a product of two functions where one function's parameters are known and the other one is a log function times an integral, i have a code where i'am doing the integration of one function first and the result i need to mutiply with the second function and take the final integral of.i have at the moment used function handles which seems to work except the results are not good:
output1=function1(input1)
output2=function(input2)
output1=@function1
return;
Thanks
Jan
Jan 2011-8-2
What does "the results are not good" mean exactly? Are they correct or do you assume a bug?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Mathematics and Optimization 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by