"Too many input arguments" with sym function
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
The following is some code that provides 16 equations:
h=.061;
h2=h/2;
h3=h2;
%Initializing constants
B(1)=0; %B 11
B(2)=0; %B 12
B(3)=0; %B 13
B(4)=0; %B 14
B(5)=0; %B21,B31
B(6)=0; %B22,B32
B(7)=0; %B23,B33
B(8)=0; %B24,B34
B(9)=0; %B41
B(10)=0; %B42
B(11)=0; %B43
B(12)=0; %B44
B(13)=0; %C20
B(14)=0; %C21
B(15)=0; %C30
B(16)=0; %C31
k1 = sym('((m1*omega^2)/D1)^(1/4)'); %Vibration modes
k2 = sym('((m2*omega^2)/D2)^(1/4)');
k3 = sym('((m3*omega^2)/D3)^(1/4)');
k4 =sym('((m4*omega^2)/D4)^(1/4)');
u2 = sym('B(13)+B(14)*x'); %Axial modes
u3 = sym('B(15)+B(16)*x');
%Initial equation
W = sym('[B(1)*cosh(k1*x)+B(2)*sinh(kl*x)+B(3)*cos(kl*x)+B(4)*sin(kl*x);B(5)*cosh(k2*x)+B(6)*sinh(k2*x)+B(7)*cos(k2*x)+B(8)*sin(k2*x);B(5)*cosh(k3*x)+B(6)*sinh(k3*x)+B(7)*cos(k3*x)+B(8)*sin(k3*x);B(9)*cosh(k4*x)+B(10)*sinh(k4*x)+B(11)*cos(k4*x)+B(12)*sin(k4*x)]');
% 16 coupled equations
h1 = sym(W,1,1); %Equation 1 @x=O
h2 = diff(h1,'x'); %Equation 2
w4 = sym(W,4,1);
h3 = diff(w4,'x',2); %Equation 3 @x=L
h4 = diff(w4,'x',3); %Equation 4
h5 = symsub(h1,sym(W,2,1)); %Equation 5 @x=xl
dw2 = diff(sym(W,2,1),'x');
h6 = symsub(h2,dw2); %Equation 6
V1 =symmul('-D1',diff(h1,'x',3)); %Force equations
V2 =symmul('-D2',diff(sym(W,2,1),'x',3));
V3 =symmul('-D3',diff(sym(W,3,1),'x',3));
V4 =symmul('-D4',diff(w4,'x',3));
h7 = symsub(V1,symadd(V2,V3)); %Equation 7
M1 = symmul('D1',diff(h1,'x',2)); %Moment Equations
M2 =symmul('D2',diff(sym(W,2,1),'x',2));
M3 =symmul('D3',diff(sym(W,3,1),'x',2));
M4 = symmul('D4',diff(w4,'x',2));
P2 = symmul('A2',diff(u2,'x')); %Axial Force Equations
P3 =symmul('A3',diff(u3,'x'));
h8a = symsub(M1,symadd(M2,M3));
h8 = symsub(h8a,symsub(symmul('(h2-h3/2)',P3),symmul('(h/2-h2/2)',P2))); %Equation 8
h9 = symadd(u2,symmul('(h/2-h2/2)',h2)); %Equation 9
h10 = symsub(u3,symmul('(h/2-h3/2)',h2)); %Equation 10
h11 = symadd(P2,P3); %Equation 11
h12 = symsub(sym(W,2,1),w4); %Equation 12 @x=x2
h13 = symsub(dw2,diff(w4,'x')); %Equation 13
h14 = symsub(V4,symadd(V2,V3)); %Equation 14
h15a =symsub(M4,symadd(M2,M3));
h15 = symsub(h15a,symsub(symmul('(h/2-h3/2)',P3),symmul('(h/2-h2/2)',P2))); %Equation 15
h16 =symsub(u2,symsub(u3,symmul('(h/2)',diff(w4,'x'))));%Equation 16
%-----------------------------------------------------------------------------------
The following line is the problem:
h1 = sym(W,1,1);
The line does not run and the error says that there are too many input arguments. I know for a fact that this code has worked previously for another person but not working with me.
If anybody can help me in this I would greatly appreciate it.
Rizwan,
5 Commenti
Risposte (1)
Walter Roberson
il 11 Mag 2017
h1 = sym(W,1,1);
has only ever been valid syntax under one of the following circumstances:
- if the sym() function has been replaced by a user-defined function; or
- if the sym() function has been replaced by a third-party function; or
- if somewhere between the assignment to W and the invocation of sym(W,1,1), that an assignment has been made to a variable named sym
Now, on the other hand, it is possible for
h1 = sym(W, [1, 1])
to be valid syntax in R2010b onwards, but only if W had been assigned a character vector in some line between the assignment to W that we are shown, and the assignment to h1.
4 Commenti
Walter Roberson
il 11 Mag 2017
That code appears to be from "MODAL FREQUENCY DETECTION IN COMPOSITE BEAMS USING FIBER OPTIC SENSORS" by GILBERT WARREN SANDERS, UNIVERSITY OF MISSOURI-ROLLA, April 18, 1997, function Delam.m
The symsub() call has never been documented for MATLAB, but it is mentioned in MATLAB Numerical Calculations by César Perez Lopez, published at the end of 2014. Oddly, the book specifically mentions the Extended Symbolic Toolbox, which has not existed since R2007b.
In the meantime, define:
function C = symadd(A,B)
C = sym(A) + sym(B);
function C = symsub(A,B)
C = sym(A) - sym(B);
function C = symmul(A,B)
C = sym(A) .* sym(B);
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!