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

3 vues (au cours des 30 derniers jours)
Sarala Gurijala
Sarala Gurijala le 22 Juin 2022
Modifié(e) : Fangjun Jiang le 24 Juin 2022
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

Réponses (1)

Fangjun Jiang
Fangjun Jiang le 23 Juin 2022
Modifié(e) : Fangjun Jiang le 24 Juin 2022
Change the last line
[d1 d2] = [Po P1ref]
to
d1 = Po;
d2 = P1ref;
or
[d1 d2] =deal(Po, P1ref)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by