How to make a dependent variable real?
7 次查看(过去 30 天)
显示 更早的评论
Hello
I want to define a variable which is dependent on time and which is real.
--> theta(t)
when I try it like that:
syms theta(t) real
it doesn't work. When I use
theta=sym('theta(t)')
it is not real. The combination
theta=sym('theta(t)','real')
doesn't work.
The problem is, that I want to transpose a matrix and it gives conj(theta) instead of theta and so simplify doesn't work.
How can I define a variable which is dependant on t and real on the same time? I think this should be possible.
0 个评论
回答(2 个)
Andrew Newell
2011-11-17
To avoid conjugation, just use
theta.'
instead of
theta'
(See Matrix and array arithmetic.) However, if your matrix is indeed real, it shouldn't make a difference.
0 个评论
Walter Roberson
2011-11-17
When you write theta(t), do you mean the function theta applied to the argument t, or do you mean the array theta indexed at index t?
In the symbolic toolbox, the () notation is for functions, and indexing is denoted by [] .
You cannot apply a transpose operator to a function.
To be able to use linear algebra operators such as transpose on an array, you should create the array within MuPAD, using MuPAD's matrix() function. (The more obvious MuPAD array() function has only limited support within the MuPad linag:: package).
The MuPAD matrix() and array() functions are for defining arrays with fixed dimensionality and matrix bounds. The MuPAD generalized expandable storage mechanism (which you would use if you wanted to be able to expand the array) is table() -- but linalg:: is not usable with table objects.
I am not certain from the documentation, but it appears that you can possibly use MuPAD's assume() with a matrix. For example,
Thingy = feval(symengine, 'assume', 'matrix(4,4)', 'Type::Real');
But this would still assume you knew the matrix dimensions.
If you need your routine to work with arrays of varying size, then I suggest you more or less drop in to MuPAD and do your calculations there, calling directly upon routines such as linalg::transpose() with respect to a symbolic variable that has not been specifically declared to be an array.
I might have missed something along the way, as the MuPAD type system works differently than Maple's.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!