Borrar filtros
Borrar filtros

matlab function generator output

1 visualización (últimos 30 días)
MUKHTAR MISBAHU UMAR
MUKHTAR MISBAHU UMAR el 14 de Feb. de 2019
Comentada: MUKHTAR MISBAHU UMAR el 14 de Feb. de 2019
I am trying to write a function that calculates power output of a generator fulfilling constraints.
Ouput = (lambda - b)/2r if Pg_min <= (lambda - b)/2r <= Pg_max
output = Pg_min if (lambda - b)/2r <= Pg_min
output = Pg_max if (lambda - b)/2r <= Pg_max

Respuesta aceptada

Mark Sherstan
Mark Sherstan el 14 de Feb. de 2019
You can define some of the variables in the function to reduce the inputs but this should get you started. I would also double check your <= and >= I dont think they make sense.
function [out] = powerOutput(lambda,Pg_min,Pg_max,b,r)
condition = (lambda - b) / (2*r);
if (Pg_min <= condition) && (condition <= Pg_max)
out = (lambda - b) / (2*r);
elseif condition <= Pg_min
out = Pg_min;
elseif condition <= Pg_max
out = Pg_max;
else
error('Conditions not met');
return;
end
end
  1 comentario
MUKHTAR MISBAHU UMAR
MUKHTAR MISBAHU UMAR el 14 de Feb. de 2019
Thank you so much, I've got 1 more problem if you are willing to help. I want to write a function for lagrange lambda with the equation below
lambda(i)(k+1) = Sum( Aij*lambda(j)(k)) + Kp*2r(i)*P(i)(k))
where aij is a matrix
lambda updates every step
Thank you for the help

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by