フィルターのクリア

error in space vector modulation function .

1 回表示 (過去 30 日間)
Mohit kumar
Mohit kumar 2021 年 3 月 28 日
コメント済み: Mohit kumar 2021 年 4 月 4 日
I have written a code in matlab function block to generate switching pulses for three phase VSI ,but i am getting an error ,please suggest something valuable. Thanks in advance.
code:
%Inputs are magnitude u1(:),angle u2(:)
%ramp signal for comparison u3(:)
function [sa,sb,sc]=AAA(u)
ts=0.0002; Vdc=1; peak_peak_max=Vdc/sqrt(3);
x=u(1);y=u(2); mag=(u/peak_peak_max)*ts;
% sector 1
if (x >=0) && (x < (pi/6))
ta=mag*sin(pi/3 - x); tb=mag*sin(x);
to=(ts-ta-tb);
t1=[ to/2,ta/2, tb/2, tb/2, ta/2, to/2];
t1=cumsum(t1);
v1=[ 1, 1, 1,1,1,1]; v2=[1,1,0,0,1,1]; v3=[1,0,0,0,0,1];
for j= 1:6
if (y < t1(j))
break
end
end
sa=v1(j);sb=v2(j); sc=v3(j);
% sector 1.1
elseif(x >=pi/6) && (x < (pi/3))
adv=x-pi/6;
ta=mag*sin(pi/3 - adv); tb=mag*sin(adv);
to=(ts-ta-tb);
t1=[ to/2,ta/2, tb/2, tb/2, ta/2, to/2];
t1=cumsum(t1);
v1=[ 0, 1, 1,1,1,0]; v2=[0,0,1,1,0,0]; v3=[0,0,0,0,0,0];
for j= 1:6
if (y < t1(j))
break
end
end
sa=v1(j);sb=v2(j); sc=v3(j);
%sector 2
elseif (x >=pi/3) && (x < (pi/2))
adv = x-pi/3;
ta=mag*sin(pi/3 - adv); tb=mag*sin(adv);
to=(ts-ta-tb);
t1=[ to/2,ta/2, tb/2, tb/2, ta/2, to/2];
t1=cumsum(t1);
v1=[ 0, 0, 1,1,0,0]; v2=[0,1,1,1,0,0]; v3=[0,0,0,0,0,0];
for j= 1:6
if (y < t1(j))
break
end
end
sa=v1(j);sb=v2(j); sc=v3(j);
% sector 2.1
elseif (x >=pi/2) && (x < (2*pi/3))
adv=x-pi/2;
ta=mag*sin(pi/3 - adv); tb=mag*sin(adv);
to=(ts-ta-tb);
t1=[ to/2,ta/2, tb/2, tb/2, ta/2, to/2];
t1= cumsum(t1);
v1=[ 1, 1, 0,0,1,1]; v2 =[1,1,1,1,1,1]; v3 = [1,0,0,0,0,1];
for j= 1:6
if (y < t1(j))
break
end
end
sa=v1(j);sb=v2(j); sc=v3(j);
% sector 3
elseif (x >=2*pi/3) && (x < (5*pi/6))
adv = x-2*pi/3;
ta= mag*sin(pi/3 - adv); tb= mag*sin(adv);
to=(ts-ta-tb);
t1=[ to/2,ta/2, tb/2, tb/2, ta/2, to/2];
t1= cumsum(t1);
v1=[ 1,0,0,0,0,1]; v2 =[1,1,1,1,1,1]; v3 = [1,1,0,0,1,1];
for j= 1:6
if (y < t1(j))
break
end
end
sa=v1(j);sb=v2(j); sc=v3(j);
% sector 3.1
elseif (x >=5*pi/6) && (x < pi )
adv = x- 5*pi/6;
ta= mag*sin(pi/3 - adv); tb= mag*sin(adv);
to=(ts-ta-tb);
t1=[ to/2,ta/2, tb/2, tb/2, ta/2, to/2];
t1= cumsum(t1);
v1=[0,0,0,0,0,0]; v2 =[0,1,1,1,1,0]; v3 = [0,0,1,1,0,0];
for j= 1:6
if (y < t1(j))
break
end
end
sa=v1(j);sb=v2(j); sc=v3(j);
% sector 4
elseif (x >=pi) && (x < 7*pi/6 )
adv = x- pi;
ta= mag*sin(pi/3 - adv); tb= mag*sin(adv);
to=(ts-ta-tb);
t1=[ to/2,ta/2, tb/2, tb/2, ta/2, to/2];
t1= cumsum(t1);
v1=[1,0,0,0,0,1]; v2 =[1,1,0,0,1,1]; v3 = [1,1,1,1,1,1];
for j= 1:6
if (y < t1(j))
break
end
end
sa=v1(j);sb=v2(j); sc=v3(j);
% sector 4.1
elseif (x >=7*pi/6) && (x < 4*pi/3 )
adv = x- 7*pi/6;
ta= mag*sin(pi/3 - adv); tb= mag*sin(adv);
to=(ts-ta-tb);
t1=[ to/2,ta/2, tb/2, tb/2, ta/2, to/2];
t1= cumsum(t1);
v1=[1,0,0,0,0,1]; v2 =[1,1,0,0,1,1]; v3 = [1,1,1,1,1,1];
for j= 1:6
if (y < t1(j))
break
end
end
sa=v1(j);sb=v2(j); sc=v3(j);
% sector 5
elseif (x >=4*pi/3) && (x < 3*pi/2 )
adv = x- 4*pi/3;
ta= mag*sin(pi/3 - adv); tb= mag*sin(adv);
to=(ts-ta-tb);
t1=[ to/2,ta/2, tb/2, tb/2, ta/2, to/2];
t1= cumsum(t1);
v1=[0,0,0,1,1,0]; v2 =[0,0,0,0,0,0]; v3 = [0,1,1,1,1,0];
for j= 1:6
if (y < t1(j))
break
end
end
sa=v1(j);sb=v2(j); sc=v3(j);
%sector 5.1
elseif (x >=3*pi/2) && (x < 5*pi/3 )
adv = x- 3*pi/2;
ta= mag*sin(pi/3 - adv); tb= mag*sin(adv);
to=(ts-ta-tb);
t1=[ to/2,ta/2, tb/2, tb/2, ta/2, to/2];
t1= cumsum(t1);
v1=[1,1,0,0,1,1]; v2 =[1,0,0,0,0,1]; v3 = [1,1,1,1,1,1];
for j= 1:6
if (y < t1(j))
break
end
end
sa=v1(j);sb=v2(j); sc=v3(j);
%sector 6
elseif (x >=5*pi/3) && (x < 11*pi/6 )
adv = x- 5*pi/3;
ta= mag*sin(pi/3 - adv); tb= mag*sin(adv);
to=(ts-ta-tb);
t1=[ to/2,ta/2, tb/2, tb/2, ta/2, to/2];
t1= cumsum(t1);
v1=[0,1,1,1,1,0]; v2 =[0,0,0,0,0,0]; v3 = [0,0,1,1,0,0];
for j= 1:6
if (y < t1(j))
break
end
end
sa=v1(j);sb= v2(j); sc= v3(j);
%sector 6.1
elseif (x >=11*pi/6) && (x < 2*pi )
adv = x- 11*pi/6;
ta= mag*sin(pi/3 - adv); tb= mag*sin(adv);
to=(ts-ta-tb);
t1=[ to/2,ta/2, tb/2, tb/2, ta/2, to/2];
t1= cumsum(t1);
v1=[1,1,1,1,1,1]; v2 =[1,0,0,0,0,1]; v3 = [1,1,0,0,1,1];
for j= 1:6
if (y < t1(j))
break
end
end
sa=v1(j);sb= v2(j); sc= v3(j);
end
Error i am getting: not able to relate like what it is talking about.

回答 (1 件)

Chidvi Modala
Chidvi Modala 2021 年 3 月 31 日
Reason : Your 'x' might fall out of the ranges you've specified. Hence the error 'Output argument sa is not assigned on some execution paths'
Workaround : You may try assigning an initial value for sa or you can replace the last elseif with else, whichever suits your case.
  1 件のコメント
Mohit kumar
Mohit kumar 2021 年 4 月 4 日
okay sir, I will try it out. Thank you for your precious advice.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSwitches and Breakers についてさらに検索

タグ

製品


リリース

R12.1

Community Treasure Hunt

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

Start Hunting!

Translated by