how to use the output of a user defined function as the input of another user defined function?

조회 수: 7 (최근 30일)
how to use the output of a user defined function as the input of another user defined function?

채택된 답변

Walter Roberson
Walter Roberson 2021년 11월 11일
Example
x = 13.5
x = 13.5000
my_cube_root(twice(x))
ans = 3
function r = my_cube_root(v)
r = nthroot(v, 3);
end
function r = twice(v)
r = 2*v;
end
The output of the user-defined function twice is used as the input to the user-defined function my_cube_root

추가 답변 (1개)

Awais Saeed
Awais Saeed 2021년 11월 11일
num = 1:10;
[S] = Addition(num)
S = 55
[M] = multiply(S) % pass output of function 1 as input to function 2
M = 275
% function 1
function [S] = Addition(num)
S = sum(num);
end
% function 2
function [M] = multiply(S)
M = S*5;
end

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by