how do I fix this code

Review the blank flowchart in the figure window.
Use it to create a function with 1 output argument (out1)
and 2 input arguments (in1 and in2) named Fa20_Q2_translate.
Input in1 must be greater than 22.
Input in2 must be a positive integer.
If either input argument is invalid, the function will return
a specific negative value as the output argument.
function out1 = Fa20_Q2_translate(in1,in2)
%UDF functions
a= in1>22; <-- %(this line doesnt work)
b= in2>0;
value = -24;
if ~(in1 > 22 || in2 >0)
disp(value)
end
end

4 comentarios

KSSV
KSSV el 28 de Sept. de 2020
What do you mean by this line is not working? I think code is fine.
Eti Rastogi
Eti Rastogi el 28 de Sept. de 2020
Not enough input arguments.
Error in Fa20_Q2_translate (line 3)
a= in1>22;
it keeps telling me that
Rui Zhao
Rui Zhao el 28 de Sept. de 2020
maybe in1(in1>22); ?
Eti Rastogi
Eti Rastogi el 28 de Sept. de 2020
no it didnt work

Iniciar sesión para comentar.

Respuestas (1)

KSSV
KSSV el 28 de Sept. de 2020

0 votos

You should not run the function by hitting the run button...you should define the input variables and then call the function.
in1 = 25 ;
in2 = 5 ;
out1 = Fa20_Q2_translate(in1,in2) ;% call the fucntion
You have to make few changes in the function.
function out1 = Fa20_Q2_translate(in1,in2)
%UDF functions
a= in1>22; <-- %(this line doesnt work)
b= in2>0;
out1 = 1 ; % if the condition is obeyed
value = -24;
if ~(in1 > 22 || in2 >0)
disp(value)
out1 = 0 ; % if the condition is not obeyed
end
end

Preguntada:

el 28 de Sept. de 2020

Respondida:

el 28 de Sept. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by