Alternative to the sym function
显示 更早的评论
if true
% In this part, we estimate the orbit of the asteroid from the data in
% d.x and d.y
x = d.x;
y = d.y;
% The orbit of an asteroid is given by a conic
% (*) y = c(1)*x.^2 + c(2)*x.*y+c(3)*y.^2+c(4)*x+c(5)
% Find the matrix A and the vector b.
x = sym('x', [10 1]);
y = sym('y', [10 1]);
A =[x.^2 x.*y y.^2 x ones(10,1)]
b = sym('y', [10,1])
% Find the size of the matrix A
[r,c]=size(A);
size(A)
% The problem is overdetermined. Solve it in the Least Squares sense,
% using the Normal Equations.
c = sym('c', [5,1]) % FIX THIS
end
Right, so this code works on a R2013a student version. When I put it into the computers at my uni it doest work. Gives me the following error Undefined function 'sym' for input arguments of type 'char'. After looking it up online, it says that the sym variable is an add on option for the academic version which we dont have. Is there another way to go about it?
2 个评论
Salaheddin Hosseinzadeh
2014-3-14
What if you define functions instead of symbolic math?!
Like for A, you can define it as a function!! What do you want to do? And why do you want to have symbolic math? Is there a specific reason that you think you won't be able to achieve by defining a funcion?
Michelle Ashwini
2014-3-14
回答(2 个)
Marta Salas
2014-3-15
Something like this displays your matrix, but this is display purpose only
s = sprintf( 'A=[\n')
for i= 1: 10
s= [s sprintf('x(%i)^2 x(%i)*y(%i) y(%i)^2 x(%i) 1;\n',i,i,i,i,i)];
end
s = [s sprintf( ']\n')];
disp(s)
Walter Roberson
2014-3-14
0 个投票
The Symbolic Toolbox has been included in all Student Version licenses up to and including R2013a. Starting in R2014a, there are two Student Version licenses available; the Bundled one corresponds to the previous license and includes Symbolic Toolbox, but the Unbundled Student Version does not include it (but makes it available for purchase.)
Note that even if a license includes the software, the software is not installed by default, so if you are using any Student Version other than R2014a Unbundled then go back to your software distribution.
9 个评论
Michelle Ashwini
2014-3-14
Walter Roberson
2014-3-14
R2012b has no Student Version. For Academic licenses, whether it is included or not depends on what the institution negotiated with Mathworks. The Symbolic Toolbox can be purchased from MATLAB for use with the Academic licenses -- but R2012b is old enough now that the mechanism to purchase it would require paying back-payments for support from R2012b to R2014a and then purchasing for R2014a. Then, with a R2014a license, the Symbolic Toolbox could be used for R2012b (all previous versions are licensed as well.)
You can use license() with 'check' option to check to see if you are licensed for using the Symbolic Toolbox (and just do not happen to have it installed.) You can use
which -all syms
to check to see if the software is installed; if it shows up but has a note that no license is available then you would know.
Michelle Ashwini
2014-3-14
Walter Roberson
2014-3-14
Are you certain that the university is not licensed for Symbolic Toolbox but has not happened to install it for your use? The license() check function can tell you whether the software is licensed (but possibly not installed.)
Licenses for the Symbolic Toolbox can be purchased for university use, with the back-payment issue I mentioned.
Meanwhile you did not respond to the question of whether this is just for display purposes that literal 'x(9)' must be shown, or if this is for numeric work.
Michelle Ashwini
2014-3-14
Marta Salas
2014-3-14
Do you have to display:
A = [x(1)^2 x(1)*y(1) y(1)^2 x(1) 1;
x(2)^2 x(2)*y(2) y(2)^2 x(2) 1;
x(3)^2 x(3)*y(3) y(3)^2 x(3) 1;
x(4)^2 x(4)*y(4) y(4)^2 x(4) 1;
x(5)^2 x(5)*y(5) y(5)^2 x(5) 1;
x(6)^2 x(6)*y(6) y(6)^2 x(6) 1;
x(7)^2 x(7)*y(7) y(7)^2 x(7) 1;
x(8)^2 x(8)*y(8) y(8)^2 x(8) 1;
x(9)^2 x(9)*y(9) y(9)^2 x(9) 1;
x(10)^2 x(10)*y(10) y(10)^2 x(10) 1 ]
or if you have a numeric value for those variables you can display the value?
for example: x(n) =y(n) = 1;
A =
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
Michelle Ashwini
2014-3-14
Walter Roberson
2014-3-15
Then you will need to construct it as strings using sprintf() or fprintf() or strcat(). Unless you manage to get the symbolic toolbox.
Michelle Ashwini
2014-3-15
类别
在 帮助中心 和 File Exchange 中查找有关 Conversion Between Symbolic and Numeric 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!