I get an error when trying to run my function using a simulink block.

function [DefuelSwitch, Defuel, EnginesOnSwitch] = defuelingtrigger(u)
% Unpack the inputs
time = u(1);
%fprintf('Pilot: Time[%f]\n',time);
% Switches
DefuelSwitchInput = u(2);
EnginesOnSwitchInput = u(3);
Defuel = u(4);
DefuelSwitch = DefuelSwitchInput;
EnginesOnSwitch = EnginesOnSwitchInput;
Defuel = -(RefuelQuantity) ;
if (DefuelSwitch == 1) && (EnginesOnSwitch == 1)
DefuelSwitch = 0;
EnginesOnSwitch = 0;
disp('Both switches can not be ON at the same time')
y = [DefuelSwitch, Defuel, EnginesOnSwitch];
end
% Pack the outputs
y(2) = DefuelSwitch;
y(4) = Defuel;
y(3) = EnginesOnSwitch;
end
%the imputs are in my simulink model and its only returning one output.
% im a novice so any suggestions will be appreciated!

4 comentarios

This is your MATLAB code and what about your Simulink model?
it returns one output for some reason
osman cusmaan
osman cusmaan el 28 de Dic. de 2022
Editada: osman cusmaan el 28 de Dic. de 2022
its the matlab code for the block

Iniciar sesión para comentar.

 Respuesta aceptada

if (DefuelSwitch == 1) && (EnginesOnSwitch == 1)
If that condition is not true, you do not assign anything to y, but you need the value of y after the end of the if statement.

2 comentarios

thanks alot! I'm on the next level of errors now! (i'm making this a game before i lose my mind)
i'll let you know when i beat the boss error XD

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre General Applications en Centro de ayuda y File Exchange.

Productos

Versión

R2022b

Preguntada:

el 28 de Dic. de 2022

Comentada:

el 29 de Dic. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by