Symbols vs Floating points

This question has to do with the question in this link which Jan has kindly shed some light on.
As mentioned in my comment, I am wondering why my x0 is of class 'sym'. I tried playing around with it and discovered that the problem lies with c0=f(a0,b0).
But I don't know what I can do with it to make it a 'double'. The thing is c0 is a number, no?

5 件のコメント

Richard
Richard 2012 年 3 月 28 日
When I run the code without c0, I get, for example
{x0 =
10 10}
class(x0)=double
whereas with c0, I get
{x0=
[10, 10, 20]}
,say, and
class(x0)=sym
So Matlab does get numbers, I don't know why the square brackets though and why the class.
Jan
Jan 2012 年 3 月 28 日
Please post the definition of "f", "a0" and "bo". Otherwise we cannot guess what's going on.
Jan
Jan 2012 年 3 月 28 日
The square brackets mean, that the value is a vector. I'm not sure, why the curly braces appear.
Richard
Richard 2012 年 3 月 28 日
Thanks, Jan.
f = @(a,b) diff(100*a^5+b, sym('a'));
a0=10;
b0=10;
c0=f(a0,b0);
x0 = [a0,b0,c0];
The curly brackets aren't actually there (though the square ones are) -- I thought that using the curly ones in this forum gives the code font -- sorry it is really me being stupid!
Jan
Jan 2012 年 3 月 28 日
The formatting in this forum is not intuitive.

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

 採用された回答

Jan
Jan 2012 年 3 月 28 日

1 投票

Your f contains the term "sym('a')". Therefore the results get the type sym also. Perhaps you want to use the command double to make the symbolic expression numerically.

1 件のコメント

Richard
Richard 2012 年 3 月 28 日
Hi, Jan, Thanks a lot! It is fixed now! :)

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

その他の回答 (0 件)

製品

質問済み:

2012 年 3 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by