Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a function in Matlab that produces three specific results. I want to use these results as input arguments to a following function to calculate the end result.

How do I go about combining the two functions?

share|improve this question

Not quite sure if I understand your question. As far as I understand you have a function1 that gives three output arguments that you want to use as inputs to a function2. In that case you could either just let the functions be separate and use them as

[a,b,c] = function1();
endResult = function2(a,b,c);

Or you could nest them by putting function1 within function2. You would do that by just appending function1 to the function2 file. In shell:

cat function2.m function1.m > function2.m

or just use an editor. You will have to edit the new function anyway, e.g. by adding the two Matlab code lines above just before defining function1.m.

Is that any help?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.