Index exceeds the number of array elements
显示 更早的评论
clc
clear
r=0;x=9;
wg=40e6; vo=30e3;voa=0;
for j=1:121
pf(j)=0.4+0.01*(j-1);
if pf<=1
cons(j)=acos(pf(j));
elseif pf>1
cons(j)=-acos(2-pf(j));
end
ia(j)=(wg./(sqrt(3).*vo.*abs(pf(j)))).*(cos(acos(pf(j)))+sin(cons(j)).*i);
eph(j)=(vo./(sqrt(3))).*(cosd(voa)+sind(voa).*i)+ia(j)*(r+i*x);
E(j)=sqrt(3).*abs(eph(j));
Ifex(j)=abs(E(j))./3464.1;
iax(j)=abs(ia(j));
end
plot(Ifex,iax)
grid
xlabel('Field current (A)')
ylabel('Armature current (A)')
title('V curve of synch. generator')
if i juse else only in the if statement, the code will run but the plot will be incomplete, and if i put elseif pf>1, I get an error
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!