why I'm getting error in MATLAB function block coding showing that parse error?

5 visualizaciones (últimos 30 días)
hi
I'm getting the error in 'MATLAB function' block that expected a function call on the RHS of this assignment.
here is my code.
function [d1, d2] = fcn(Po, P1ref)
Pmax = 50;
if Po > Pmax
d1 = 1;
d2 = 1;
end
if Po < Pmax && Po >= P1ref
d1 = 1;
d2 = 0;
elseif Po < P1ref
d1 = 0;
d2 = 0;
end
[d1 d2] = [Po P1ref];
outputs are d1,d2. inputs are Po and P1ref. please help me to rectify the error in above code.
Thanks in advance

Respuestas (1)

Fangjun Jiang
Fangjun Jiang el 23 de Jun. de 2022
Editada: Fangjun Jiang el 24 de Jun. de 2022
Change the last line
[d1 d2] = [Po P1ref]
to
d1 = Po;
d2 = P1ref;
or
[d1 d2] =deal(Po, P1ref)

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by