Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Passing data between fucntions

조회 수: 2 (최근 30일)
Adam Silva
Adam Silva 2014년 10월 19일
마감: MATLAB Answer Bot 2021년 8월 20일
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

답변 (1개)

Star Strider
Star Strider 2014년 10월 19일
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
Adam Silva
Adam Silva 2014년 10월 20일
Thanks. It works.
Star Strider
Star Strider 2014년 10월 20일
My pleasure!
The most sincere expression of appreciation here on MATLAB Answers is to Accept the answer that most closely solves your problem.

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by