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

1 次查看(过去 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