Alternative to the sym function
37 views (last 30 days)
Show older comments
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 Comments
Salaheddin Hosseinzadeh
on 14 Mar 2014
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?
Answers (2)
Marta Salas
on 15 Mar 2014
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
on 14 Mar 2014
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 Comments
Walter Roberson
on 15 Mar 2014
Then you will need to construct it as strings using sprintf() or fprintf() or strcat(). Unless you manage to get the symbolic toolbox.
See Also
Categories
Find more on Assumptions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!