Don’t understand the reason this code is giving me errors.
The code that is producing the error is below. It says:
>> test
Error: File: test.m Line: 32 Column: 58
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
>> test
Error: File: test.m Line: 30 Column: 60
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
Code that produces errors is below.
clc;
mass = 13.5;
Jx = 0.8244;
Jy = 1.135;
Jz = 1.759;
Jxz = 0.1204;
G = Jx*Jz-Jxz^2;
G1 = Jxz*(Jx – Jy + Jz)/G;
G2 = (Jz*(Jz-Jy)+Jxz^2)/G;
G3 = Jz/G;
G4 = Jxz/G;
G5 = (Jz-Jx)/Jy;
G6 = Jxz/Jy;
G7 = ((Jx-Jy)*Jx +Jxz^2)/G;
G8 = (Jx/G);
p = 0;
q = 0;
r = 0;
l = 0.0000;
m = 0.0000;
n = 0.0000;
tspan = [0 10];
%[t,q] = ode45(@(t,q) (G5*p*r-G6*(p^2-r^2)+m/Jy), tspan,0);
%plot(t,q);
%pdot = (G1*p*q-G2*q*r + G3*l+G4*n);
[t,p]=ode45(@(t,p) (G1*p*q-G2*q*r+G3*l+G4*n),[0 10], 0.1);
plot(t,p,’–r’);
disp(p);
disp(t);
[t,q] = ode45(@(t,r) (G5*p*r-G6*p*p-G6*r*r)+m/Jy), [0 10],0);
plot(t,q,’–g’);
[t,r] = ode45(@(t,r) (G7*p*q-G1*q*r + G4*l+G8*n), [0 10],0);
plot(t,r,’–b’)The code that is producing the error is below. It says:
>> test
Error: File: test.m Line: 32 Column: 58
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
>> test
Error: File: test.m Line: 30 Column: 60
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
Code that produces errors is below.
clc;
mass = 13.5;
Jx = 0.8244;
Jy = 1.135;
Jz = 1.759;
Jxz = 0.1204;
G = Jx*Jz-Jxz^2;
G1 = Jxz*(Jx – Jy + Jz)/G;
G2 = (Jz*(Jz-Jy)+Jxz^2)/G;
G3 = Jz/G;
G4 = Jxz/G;
G5 = (Jz-Jx)/Jy;
G6 = Jxz/Jy;
G7 = ((Jx-Jy)*Jx +Jxz^2)/G;
G8 = (Jx/G);
p = 0;
q = 0;
r = 0;
l = 0.0000;
m = 0.0000;
n = 0.0000;
tspan = [0 10];
%[t,q] = ode45(@(t,q) (G5*p*r-G6*(p^2-r^2)+m/Jy), tspan,0);
%plot(t,q);
%pdot = (G1*p*q-G2*q*r + G3*l+G4*n);
[t,p]=ode45(@(t,p) (G1*p*q-G2*q*r+G3*l+G4*n),[0 10], 0.1);
plot(t,p,’–r’);
disp(p);
disp(t);
[t,q] = ode45(@(t,r) (G5*p*r-G6*p*p-G6*r*r)+m/Jy), [0 10],0);
plot(t,q,’–g’);
[t,r] = ode45(@(t,r) (G7*p*q-G1*q*r + G4*l+G8*n), [0 10],0);
plot(t,r,’–b’) The code that is producing the error is below. It says:
>> test
Error: File: test.m Line: 32 Column: 58
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
>> test
Error: File: test.m Line: 30 Column: 60
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
Code that produces errors is below.
clc;
mass = 13.5;
Jx = 0.8244;
Jy = 1.135;
Jz = 1.759;
Jxz = 0.1204;
G = Jx*Jz-Jxz^2;
G1 = Jxz*(Jx – Jy + Jz)/G;
G2 = (Jz*(Jz-Jy)+Jxz^2)/G;
G3 = Jz/G;
G4 = Jxz/G;
G5 = (Jz-Jx)/Jy;
G6 = Jxz/Jy;
G7 = ((Jx-Jy)*Jx +Jxz^2)/G;
G8 = (Jx/G);
p = 0;
q = 0;
r = 0;
l = 0.0000;
m = 0.0000;
n = 0.0000;
tspan = [0 10];
%[t,q] = ode45(@(t,q) (G5*p*r-G6*(p^2-r^2)+m/Jy), tspan,0);
%plot(t,q);
%pdot = (G1*p*q-G2*q*r + G3*l+G4*n);
[t,p]=ode45(@(t,p) (G1*p*q-G2*q*r+G3*l+G4*n),[0 10], 0.1);
plot(t,p,’–r’);
disp(p);
disp(t);
[t,q] = ode45(@(t,r) (G5*p*r-G6*p*p-G6*r*r)+m/Jy), [0 10],0);
plot(t,q,’–g’);
[t,r] = ode45(@(t,r) (G7*p*q-G1*q*r + G4*l+G8*n), [0 10],0);
plot(t,r,’–b’) error in calling runge kutta 4 function. MATLAB Answers — New Questions