creating square wave problem

3 ビュー (過去 30 日間)
BARAN Özbakr
BARAN Özbakr 2014 年 3 月 7 日
編集済み: Mischa Kim 2014 年 3 月 7 日
Hi everyone:
I have problem in simulink. I created sinus signal, it´s amplitude is 1 and freq is 50 Hz. Then I used "user defined function" and write down this code : here u equals sin function. I divided sinus function in 4 parts, as you can see in code. But the output was not as expected. ANY SUGGESTION ? it only gives -0.8
function y = fcn(u)
y=0;
if(0<=u<0.5)
y=0.2;
end
if (0.5<=u<=1)
y=0.7;
end
if (0>=u>-0.5)
y=-0.3;
end
if (-0.5>=u>=-1)
y=-0.8;
end
end

採用された回答

Mischa Kim
Mischa Kim 2014 年 3 月 7 日
編集済み: Mischa Kim 2014 年 3 月 7 日
Use
if (0<=u && u<0.5)
and accordingly for all the other if statements.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by