symprod error

23 visualizzazioni (ultimi 30 giorni)
Ima
Ima il 14 Feb 2012
Modificato: Cedric il 20 Ott 2013
The goal of the code above is to create a pre-specified number of vortices, denoted by the entries V(i). The vortices are in complex form (i.e. x+i*y etc). I would like to be able to take the symbolic product of the vortices (specified by the parameter vort_num).
For example: if I have 2 vortices V = [ x + y*i, x - 1 + y*i], then I would like psi_0 to be their symbolic product. The only problem is that I would like to be able to change the number of vortices easily, so I was trying to use the symprod function. This way I could easily expand from 2 vortices to 10,so on and so forth.
This is not working: I am getting the follow error:
??? Undefined function or method 'symprod' for input arguments of type 'sym'.
The code is:
clc;
clear;
syms x y t k;
vort_num = 2 %Set number of vortices
A = ones(vort_num,3); %Construct a 3 row matrix consisting of each vortex parameter (A(row1),B(row2),E(row3))
V = sym(ones(1,vort_num));
for k = 1:vort_num
A(k,3)=k-1 %Set displacement to be equal between each vortex, moving in the positive direction on the x-axis for each new vortex
V(k) = A(k,1)*(x-A(k,3))+i*y*A(k,2) %Create complex form of each vortex
end
psi_0 = symprod(V(k), k, 1, vort_num); %Expand initial solution in polynomial form
I tried to change V to a symbolic matrix, but I am still having some issues.
Any help that you could provide could be extremely helpful.
Thanks Ima
  2 Commenti
Walter Roberson
Walter Roberson il 14 Feb 2012
Which MATLAB version are you using?
Ima
Ima il 15 Feb 2012
Oh - sorry:
7.12.0.635 (R2011a) student version.

Accedi per commentare.

Risposte (3)

Kai Gehrs
Kai Gehrs il 5 Mar 2012
Hi Ima,
the function SYMPROD was introduced in R2011b.
In addition to that the function SYMPROD is for computing products of a (scalar) expressions.
Something like
>> syms k;
>> symprod(1/k,k,1,inf)
is the use case for this function.
But you should be able to work around the problem as follows: I think you want to use PROD (which is the symbolic overload of the usual MATLAB function for computing products) anyway.
Something like
psi_0 = prod(V)
should do the job (if I undertood you correctly). You can change the size of V to get the product of less or more elements.
Maybe this helps a bit.
Best regard,
-- Kai

Andrew Newell
Andrew Newell il 17 Feb 2012
Are you sure you have the Symbolic Toolbox? Try typing ver and see if it is one of the ones listed.
If it is listed, maybe it isn't checked out. See How would one check for installed MATLAB toolboxes in a script/function?
  2 Commenti
Ima
Ima il 17 Feb 2012
It says that I have the symbolic math toolbox version 5.6. Is this the right one?
Andrew Newell
Andrew Newell il 17 Feb 2012
I think so. See above for another suggestion.

Accedi per commentare.


Ima
Ima il 22 Feb 2012
It appears that the license is properly checked out. I ran this in Matlab:
license checkout symbolic_Toolbox
ans =
1
Could something else be causing the problem?
Thanks Ima
  1 Commento
Andrew Newell
Andrew Newell il 22 Feb 2012
Strange. I have added some more suggestions to my answer.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by