我也眼花了,我不知道要去哪里问= =
??? Error using ==> mtimes
Inner matrix dimensions must agree.
??? Error using ==> mpower
Matrix must be square.
我在写我的程序时候出现了这些,
然后我也google了说什么家点点,
例如.^2 还是x.*y之类的,
我其实也不太清楚这些怎么看,
我乱加一通结果导致不一样的程式出来的图都一样了,
有谁可以帮我解答?
目前我程序这个样子:
%physical properties of the helmholtz resonator
Vc=0.006868125;		%volume of the cavity (m)
a=0.025;			%neck radius (m)
Ln=0.015;			%neck length (m)
Sn=pi*a^2;			%cross sectional area of the neck (m^2)
rho=1.225;			%density of air @ 15degC (kgm^(-3))
c0=340.29;			%speed of sound @ 15degC (ms^(-1))
%defining plotting interval for the passive helmholtz resonator
fs=1;                                 %define start frequency 
ff=500;                              %define finish frequency
step=1;                              %frequency step size
f=fs:step:ff;			%define frequency interval and step size
%effective properties of the helmholtz resonator
Leff=Ln+1.7*a;                 %effective neck length for flanged HR
Meff=rho*Sn*Leff;               %effective mass for the lumped of air
keff=rho*(c0^2)*(Sn^2)/Vc;  	%effective stiffness in the cavity
kwav=(2*pi*f)/c0;                %wave number
Rr=rho*c0*kwav.^2*Sn^2/(2*pi);	%radiation resistance
Q=2*pi*sqrt(Vc*(Leff/Sn)^3);	%quality factor for flanged HR
f0=sqrt(keff/Meff)/(2*pi);		%w0=resonance frequency (w=2*pi*f)
Rw=f0*2*pi*Meff/Q;              %thermoviscous resistance
%orifice impedance
Zn=(Rr+Rw)+1i*(2*pi*f*Meff); %orifice impedance 
%actuator dynamics for secondary speaker
Ea=0.04;                  %actuator damping coefficient
Wa=3456;                %actuator natural frequency in rads^-1
Ga=1;                      %defining gain constant
Ha=(1i*2*pi*f*Ga)/((1i*2*pi*f).^2+2*Ea*Wa*(1i*2*pi*f)+Wa^2); %actuator dynamics
%controller transfer function
	引用:
	
	
		
			
				Kp=4;       
那两个程式也有用到这一个variable- - 
可是目前的状况,当我改Kp时候, 
plot完全不动,所以是出问题了= =+        
			
		 | 
	
	
 %value for Kp
Ns=Kp;                    %numerator for the controller transfer function
Ds=1;                      %denomenator for the controller transfer funtion
Hc=Ns/Ds;                %controller transfer function
%pressure amplification of the resonator (pressure in the cavity/external driving pressure)
	引用:
	
	
		
			
				Case 1:P=(Ds-Zn*Ha*Ns)./(Ds*(Zn.*(1i*2*pi*f)*(1/keff)+1));  
Case 2:P=Ds./(Zn.*1i*2*pi.*f*(1/keff).*Ds+Ds+Zn.*Ha.*Ns);     
程序的所有都是一样的,除了这一行, 
可是当我plot的时候,这两个出现的plot是一模一样, 
我不知道哪里出错了= =+ 
			
		 | 
	
	
 %the equivalent of pressure ratio P=Pc/Ps
Pmag=sqrt(real(P).^2+imag(P).^2);		        %magnitude of the pressure ratio
Pphase=atan(imag(P)./real(P));			%phase of the pressure ratio
PdB=20*log10(Pmag);                                   %magnitude in dB (level of sound)
%plotting command for the bode plot of passive helmholtz resonator
subplot(2,1,1)
plot(f,PdB)                                          %plotting magnitude in dB
Title('Bode plot of activeHR-case 1')
xlabel('Frequency(Hz)')
ylabel('Magnitude(dB)')
subplot(2,1,2)
plot(f,Pphase*(180/pi))				%plotting phase in degrees
xlabel('Frequency(Hz)')
ylabel('Phase(deg)')