필터 지우기
필터 지우기

How to use arguments of other m-file in another m-file?

조회 수: 3 (최근 30일)
SeokWon CHOI
SeokWon CHOI 2022년 6월 12일
답변: Voss 2022년 6월 12일
I want to use the arguments of the m file called A in the m file called B, but I don't know how.
How can I do?
for example, Use the output values ​​of a1, a2, a3 in the m file called A as the input values ​​in the m file called B.
  댓글 수: 1
Jan
Jan 2022년 6월 12일
Please post some code which creates the situation you are asking for. Do you mean scripts or functions?

댓글을 달려면 로그인하십시오.

답변 (1개)

Voss
Voss 2022년 6월 12일
% get the outputs from A:
[a1,a2,a3] = A(5);
% use them as inputs in B:
result = B(a1,a2,a3)
result = 30
function [out1,out2,out3] = A(in)
out1 = in;
out2 = in*2;
out3 = in*3;
end
function out = B(in1,in2,in3)
out = in1+in2+in3;
end

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by