symprod error
1 次查看(过去 30 天)
显示 更早的评论
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
回答(3 个)
Kai Gehrs
2012-3-5
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
0 个评论
Andrew Newell
2012-2-17
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!