symprod error

3 ビュー (過去 30 日間)
Ima
Ima 2012 年 2 月 14 日
編集済み: Cedric 2013 年 10 月 20 日
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 件のコメント
Walter Roberson
Walter Roberson 2012 年 2 月 14 日
Which MATLAB version are you using?
Ima
Ima 2012 年 2 月 15 日
Oh - sorry:
7.12.0.635 (R2011a) student version.

サインインしてコメントする。

回答 (3 件)

Kai Gehrs
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

Andrew Newell
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 件のコメント
Ima
Ima 2012 年 2 月 17 日
It says that I have the symbolic math toolbox version 5.6. Is this the right one?
Andrew Newell
Andrew Newell 2012 年 2 月 17 日
I think so. See above for another suggestion.

サインインしてコメントする。


Ima
Ima 2012 年 2 月 22 日
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 件のコメント
Andrew Newell
Andrew Newell 2012 年 2 月 22 日
Strange. I have added some more suggestions to my answer.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by