関数がある場合:
function [out1,out2,...] = functionName[in1,in2]
function code here
end
そしてもう一つの機能
function[newout1,newout2] = newfunctionName[in1,in2]
[newout1]=out1+out2;
[newout2]=out2+out3;
さまざまな出力、out1、out2、out3 などを呼び出すにはどうすればよいですか...
関数がある場合:
function [out1,out2,...] = functionName[in1,in2]
function code here
end
そしてもう一つの機能
function[newout1,newout2] = newfunctionName[in1,in2]
[newout1]=out1+out2;
[newout2]=out2+out3;
さまざまな出力、out1、out2、out3 などを呼び出すにはどうすればよいですか...
「さまざまな出力、out1、out2、out3などを呼び出す」という意味がよくわかりませんが、タイトルの質問に答えるには、
関数の n 番目の出力にアクセスするには、最初にその関数の名前でnargoutを呼び出し、次にその出力を事前に割り当てられたサイズのセルに挿入する必要があります。以下のサンプルコード、
n = 5;
nout = abs(nargout('functionName'));
if n>nout
error(['n must be lower or equal than ',num2str(nout)])
end
out = cell(1,n);
[out{:}] = functionName(in1,in2);
nth_output = out{n};
functionName
これは、パスに含まれる任意の関数内で実行できます。