why I'm getting error in MATLAB function block coding showing that parse error?
3 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Fangjun Jiang
on 23 Jun 2022
Edited: Fangjun Jiang
on 24 Jun 2022
Change the last line
[d1 d2] = [Po P1ref]
to
d1 = Po;
d2 = P1ref;
or
[d1 d2] =deal(Po, P1ref)
0 Comments
See Also
Categories
Find more on String in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!