Info

This question is closed. Reopen it to edit or answer.

Passing data between fucntions

1 view (last 30 days)
Adam Silva
Adam Silva on 19 Oct 2014
Closed: MATLAB Answer Bot on 20 Aug 2021
Hi
I have two functions: "1. inputdata.m" and "2. algorithm.m". All the input data to calculate values using algorithm.m are in inputdata.m file. I'm outputting a, bd, gas, and nopt as data from file 1.
Say I have A= ab, BD=bd, GAS=gas and NOPT=nopt in "algorithm.m". How can I load the data from algorithm.m.
Thanks

Answers (1)

Star Strider
Star Strider on 19 Oct 2014
Function files:
[a, bd, gas, nopt] = function inputdata(args)
. . . code . . .
end
[outputs] = function algorithm(a, bd, gas, nopt)
. . . code . . .
end
then in your main script:
[a, bd, gas, nopt] = inputdata(args);
[outputs] = algorithm(a, bd, gas, nopt);
  2 Comments
Adam Silva
Adam Silva on 20 Oct 2014
Thanks. It works.
Star Strider
Star Strider on 20 Oct 2014
My pleasure!
The most sincere expression of appreciation here on MATLAB Answers is to Accept the answer that most closely solves your problem.

This question is closed.

Community Treasure Hunt

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

Start Hunting!