Filter löschen
Filter löschen

Indexing error using ezplot

4 Ansichten (letzte 30 Tage)
random09983492 am 7 Aug. 2012
Hi, I'm writing a code that uses symbolic variables and ezplot. My equation contains 17 variables, and I am trying to find the derivative with respect to 16 of the 17 variables. I'm not sure if I'm approaching this the correct way. My current code takes the derivative of the equation, then I use the subs command to put in values for the other variables, then use ezplot to show the derivative. Here's a portion of my code:
syms gamma02 gamma13 Gamma02 Gamma13 tau02 tau13 Omega02 Omega13 ...
Phi02 Phi13 gamma02_1 gamma13_1 t;
gamma02 = Gamma02*cos(2*pi*tau02*t+Omega02)+Phi02;
gamma02_1 = Gamma02*cos(Omega02)+Phi02;
gamma13 = Gamma13*sin(2*pi*tau13*t+Omega13)+Phi13;
gamma13_1 = Gamma13*sin(Omega13)+Phi13;
syms Gamma02_e Gamma13_e tau02_e tau13_e Omega02_e Omega13_e Phi02_e Phi13_e psi;
U = Gamma13_e/Gamma02_e*(gamma02_1-Phi02_e)*exp(-1i*(Omega13_e-Omega02_e))+1i*(gamma13_1-Phi13_e);
theta_offset = 2*atan((sqrt(real(U).^2+imag(U).^2)-real(U))./imag(U));
U = (Gamma13_e/Gamma02_e*(gamma02-Phi02_e)*exp(-1i*(Omega13_e-Omega02_e))+1i*(gamma13-Phi13_e))*exp(1i*-theta_offset);
theta = 2*atan((sqrt(real(U).^2+imag(U).^2)-real(U))./imag(U));
syms theta_ref theta_err theta_err_rms;
theta_ref = atan(sin(2*pi*tau13*t),cos(2*pi*tau02*t));
theta_err = theta - theta_ref;
theta_err_rms = sqrt(mean(theta_err.^2));
syms dGamma02 dtau02 dOmega02 dPhi02;
dGamma02 = diff(theta_err_rms,'Gamma02');
dtau02 = diff(theta_err_rms,'tau02');
dOmega02 = diff(theta_err_rms,'Omega02');
dPhi02 = diff(theta_err_rms,'Phi02');
dGamma02 = subs(dGamma02,{Gamma02,Gamma13,Gamma13_e,tau02,tau02_e,tau13,tau13_e,Omega02,Omega02_e,Omega13,Omega13_e,Phi02,Phi02_e,Phi13,Phi13_e,t},{1,1,1,1/22,1/22,1/22,1/22,0,0,0,0,0,0,0,0,1});
As you can see, I take the derivative with respect to Gamma02, and that is the only variable I don't substitute with a number. The error I receive is this:
Error: ()-indexing must appear last in an index expression.
Error in ==> inline.feval at 36
INLINE_OBJ_.inputExpr, INLINE_OBJ_.expr);
Error in ==> ezplotfeval at 54
z = feval(f,x(1),y(1));
Error in ==> ezplot>ezimplicit at 258
u = ezplotfeval(f, X, Y);
Error in ==> ezplot at 155
hp = ezimplicit(cax, f{1}, vars, labels, args{:});
Error in ==> sym.ezplot at 45
h = ezplot(char(f));
I'm not too familiar with using symbolic variables, so maybe I am overlooking something simple. Thanks for the help.
Entire code uploaded to pastebin:
  3 Kommentare
Sean de Wolski
Sean de Wolski am 8 Aug. 2012
What does char(f) evaluate to?
Oleg Komarov
Oleg Komarov am 8 Aug. 2012
I don't any problems on R2012a Win Xp 32b

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by