function not using all values
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Alexandru Bortea
el 18 de Abr. de 2017
Respondida: Jan
el 18 de Abr. de 2017
I was creating this function for a launch control's ignition cut and when running it, the function avoid all the conditions where v appears. I am not very familiar to this kind of conditioning as I recently learnt it and it is the first time I am using it with two inputs and one output. Code and variables used can be seen below. Initially when I created the code I tried using if statements, but I soon realised when using that all values of the vectors have to be below the condition otherwise the statement jumps straight to the "else" part.
function injcut = injcut_fun (v,rpm)
global LCREV_MAX LCSPEED_MAX
injcut = rpm;
injcut (:) = 1; % 100% torque allowed
injcut (rpm > 11100) = 0; % 0% torque allowed
injcut (rpm > 10900) = 0.5; % 50% torque allowed
injcut (v <= LCSPEED_MAX/3.6 & rpm > LCREV_MAX+300) = 0; % 0% torque allowed
injcut (v <= LCSPEED_MAX/3.6 & rpm > LCREV_MAX+200) = 0.25; % 25% torque allowed
injcut (v <= LCSPEED_MAX/3.6 & rpm > LCREV_MAX+100) = 0.5; % 50% torque allowed
injcut (v <= LCSPEED_MAX/3.6 & rpm > LCREV_MAX) = 0.75; % 75% torque allowed
0 comentarios
Respuesta aceptada
Jan
el 18 de Abr. de 2017
The order matters:
injcut (v <= LCSPEED_MAX/3.6 & rpm > LCREV_MAX) = 0.75; % 75% torque allowed
injcut (v <= LCSPEED_MAX/3.6 & rpm > LCREV_MAX+100) = 0.5; % 50% torque allowed
injcut (v <= LCSPEED_MAX/3.6 & rpm > LCREV_MAX+200) = 0.25; % 25% torque allowed
injcut (v <= LCSPEED_MAX/3.6 & rpm > LCREV_MAX+300) = 0; % 0% torque allowed
In the opposite order, the value set by rpm > LCREV_MAX+300 is overwritten by rpm > LCREV_MAX.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Wind Power en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!