"Too many input arguments" with sym function

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 Comments

Adam
Adam on 11 May 2017
Edited: Adam on 11 May 2017
Also learn how to provide useful tags. I have no clue what the tags you have used are supposed to mean, but they are in no way helpful and make your problem look irrelevant rather than urgent.
Why h1 = sym(W,1,1); this is required?
@R SW: If you really mean, that your problem is more urgent than all otehr problems posted in the forum, please care about providing details: Which Matlab version are you using? In which version did it run before?
@Jan Simon R2014b is my version. The code is quite old (1997) so I don't know which version they used.
That code was not valid in the 1997 time frame either.

Sign in to comment.

Answers (1)

h1 = sym(W,1,1);
has only ever been valid syntax under one of the following circumstances:
  1. if the sym() function has been replaced by a user-defined function; or
  2. if the sym() function has been replaced by a third-party function; or
  3. 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 Comments

R SW
R SW on 11 May 2017
Edited: R SW on 11 May 2017
I just updated the question with the complete code. Please look at the complete code above to give some context. Thank you for your interest and help
Given the context, I suspect that
h1 = sym(W,1,1); %Equation 1 @x=O
should be
h1 = W(1,1); %Equation 1 @x=O
Thank you for your reply, Walter.
I changed the following upon your suggestion:
h1 = sym(W,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
into:
h1 = W(1,1); %Equation 1 @x=O
h2 = diff(h1,'x'); %Equation 2
w4 = W(4,1);
h3 = diff(w4,'x',2); %Equation 3 @x=L
h4 = diff(w4,'x',3); %Equation 4
h5 = symsub(h1,W(2,1)); %Equation 5 @x=xl
dw2 = diff(W(2,1),'x');
h6 = symsub(h2,dw2); %Equation 6
Now h5 does not get defined successfully as the error says that the input cannot be sym. Any idea what to do? I really appreciate your input
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);

Sign in to comment.

Tags

No tags entered yet.

Asked:

on 11 May 2017

Commented:

on 11 May 2017

Community Treasure Hunt

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

Start Hunting!