フィルターのクリア

Alternative to the sym function

25 ビュー (過去 30 日間)
Michelle Ashwini
Michelle Ashwini 2014 年 3 月 14 日
コメント済み: Michelle Ashwini 2014 年 3 月 15 日
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
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
Michelle Ashwini 2014 年 3 月 14 日
There's no specific reason as to why I used symbolic's. When looking up online, that seemed like a better choice. If I were to use functions instead, how would I go about it? I'm still very new to MATLAB.

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

回答 (2 件)

Marta Salas
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)
  1 件のコメント
Michelle Ashwini
Michelle Ashwini 2014 年 3 月 15 日
Thank you very much! Trying it out :)

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


Walter Roberson
Walter Roberson 2014 年 3 月 14 日
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 件のコメント
Walter Roberson
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
Michelle Ashwini 2014 年 3 月 15 日
Okay. Thanks!:)

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

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by