How to get nan as output if the function output argument is not supported?

조회 수: 2 (최근 30일)
I have written a function with three outputs.
function [logical_out, run_time, reaction_time] = reaction_time_function3(~,~,~)
% code
end
I want run_time and reaction_time output to be 'NaN' if logical_out is 0. How can I do that? In fact, I have written a piece of code not to run the script further if logical_out is 0.
% do not run further calculations if logical ouput is zero
if logical_out == 0
return
end

채택된 답변

Stephen23
Stephen23 2022년 4월 21일
if isequal(logical_out,0)
run_time = NaN;
reaction_time = NaN;
return
end

추가 답변 (1개)

Matt J
Matt J 2022년 4월 21일
if logical_out == 0
[run_time, reaction_time]=deal(nan);
return
end

카테고리

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

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by