From: Jason on
Hello all,

I have an interesting issue from my perspective. I have a program that calls a series of mfiles and uses a toolbox I did not build to solve a given problem. In order to use a certain function of the toolbox, I need the function definition line of an output mfile to read:

"function [out_1 out_2 out_3 ... out_n] = output(...)"

where out_i is the ith output, n is the total number of outputs and output is the mfile taking any given inputs to generate the outputs. The total number of outputs changes per problem.

Now my issue is that I want the output mfile to be generic in how it computes the outputs but do not know how to have it output the variable number of outputs as shown above. I could write separate output mfiles for each problem but since I can generalize them, I would like to simply use some sort of file writing scheme to write the proper function definition line and appropriate function definition line compatible script inside the function of the mfile in the beginning for the program to use.

If there is not enough information listed above to help, please let me know and I will give a more detailed problem statement. Thanks!

-jason
From: dpb on
Jason wrote:
....
> need the function definition line of an output mfile to read:
>
> "function [out_1 out_2 out_3 ... out_n] = output(...)"
> where out_i is the ith output, n is the total number of outputs and
> output is the mfile taking any given inputs to generate the outputs.
> The total number of outputs changes per problem.
>
> Now my issue is that I want the output mfile to be generic in how it
> computes the outputs but do not know how to have it output the variable
> number of outputs as shown above. I could write separate output mfiles
> for each problem but since I can generalize them, I would like to simply
> use some sort of file writing scheme to write the proper function
> definition line and appropriate function definition line compatible
> script inside the function of the mfile in the beginning for the program
> to use.
....

See

doc varargout % for ideas...

--
From: Walter Roberson on
Jason wrote:

> I have an interesting issue from my perspective. I have a program that
> calls a series of mfiles and uses a toolbox I did not build to solve a
> given problem. In order to use a certain function of the toolbox, I
> need the function definition line of an output mfile to read:
>
> "function [out_1 out_2 out_3 ... out_n] = output(...)"
> where out_i is the ith output, n is the total number of outputs and
> output is the mfile taking any given inputs to generate the outputs.
> The total number of outputs changes per problem.
>
> Now my issue is that I want the output mfile to be generic in how it
> computes the outputs but do not know how to have it output the variable
> number of outputs as shown above.

Use a single cell array for the output and let the user break it up if
they want to, using

[output1, output2, output3...] = deal(TheCellArray{:});
 | 
Pages: 1
Prev: oqpsk code
Next: Perron eigenvector