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

6 次查看(过去 30 天)
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

回答(1 个)

Fangjun Jiang
Fangjun Jiang 2022-6-23
编辑:Fangjun Jiang 2022-6-24
Change the last line
[d1 d2] = [Po P1ref]
to
d1 = Po;
d2 = P1ref;
or
[d1 d2] =deal(Po, P1ref)

类别

Help CenterFile Exchange 中查找有关 String 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by