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

6 ビュー (過去 30 日間)
Sarala Gurijala
Sarala Gurijala 2022 年 6 月 22 日
編集済み: Fangjun Jiang 2022 年 6 月 24 日
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 Center および File ExchangeString についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by