Basically I would like to call a function that I have written, and because of the amount of results, I would like the function to output its solution into 开发者_如何学Pythona matrix that gets passed to the program that called it.
You define the output of a function in the function declaration at the top of your script:
function [output] = myFunction(input)
All you need to do is define the output
variable somewhere in your script.
The confusing part (to me) was that you need to put the output variables in both your main program and your function definition. So in your main program you have:
[out1,out2,out3] = function_name(in1,in2);
and in your function definition, you have:
function [out1,out2,out3] = function_name(in1,in2).
The variables don't have to have the same name, but they need to be oriented similarly, so that you can then pass the outputs back to the main program.
精彩评论