function a =myfun(Tw2,I2,P2)
Tm=1.5;
Te=0.5;
T0=0.05;
Jw2=pi./10;
a(1)=(Jw2+atan((2*pi*Tm)./Tw2)+atan((2*pi*Te)./Tw2)+(2*pi*T0)./Tw2)-pi;
a(2)=atan(Tw2./(2*pi*I2))-Jw2;
a(3)=((100./P2)*sqrt(1+(tan(Jw2))^2)*1./sqrt(1+(Tm*2*pi./Tw2)^2)*1./sqrt(1+(0.5*2*pi./Tw2)^2))-1;
end
/*******************************
********************************/
clear
Jw22=fsolve('myfun',[2,2,3]);
不知为什么出现错误?
Subscripted assignment dimension mismatch.
Error in myfun (line 6)
a(1)=(Jw2+atan((2*pi*Tm)./Tw2)+atan((2*pi*Te)./Tw2)+(2*pi*T0)./Tw2)-pi;
Error in fsolve (line 218)
fuser = feval(funfcn{3},x,varargin{:});
Error in Test (line 2)
Jw22=fsolve('myfun',[2,2,3]);
Caused by:
Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue.

 Réponse acceptée

givesij
givesij le 17 Nov 2022

0 votes

哪是未知数呀?是这样吗?
function a=myfun(x)
%x(1)=Tw2,x(2)=I2,x(3)=P2
Tm=1.5;
Te=0.5;
T0=0.05;
Jw2=pi/10;
a(1)=(Jw2+atan((2*pi*Tm)./x(1))+atan((2*pi*Te)./x(1))+(2*pi*T0)./x(1))-pi;
a(2)=atan(x(1)./(2*pi*x(2)))-Jw2;
a(3)=((100./x(3))*sqrt(1+(tan(Jw2))^2)*1./sqrt(1+(Tm*2*pi./x(1))^2)*1./sqrt(1+(0.5*2*pi./x(1))^2))-1;
end
Jw22=fsolve('myfun',[2,2,3])
Jw22 =    1.3477    0.6601    5.8678

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB 快速入门 dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!