How can i define a m by n symbolic matrix?
2 次查看(过去 30 天)
显示 更早的评论
I know how to for example define a 3 by 4 symbolic matrix with this:
x=sym('a',[3,4])
but I don't know how to define this:
x=sym('a',[m n])
(m and n aren't variables,i just want to get something like
a11 a12 ... a1n
. . .
. . .
am1 am2 ... amn
0 个评论
采纳的回答
John D'Errico
2021-11-19
编辑:John D'Errico
2021-11-19
If m and n are themselves symbolic, you cannot do so. However, you can do this:
matfun = @(m,n) sym('a',[m,n]);
Now you can use it to create a matrix of any desired size. Thus
matfun(2,3)
matfun(4,1)
But you cannot create something of indeterminate size or dimensions.
Could you write your own class of objects, that do as you wish? Well, yes. I suppose you could. I'm not sure what value it would offer, but you would need to write the code to do so yourself. And as well, you would then need to write code to manipiulate those objects, as MATLAB will not automatically know how to multiply such objects without your explicit direction.
更多回答(1 个)
the cyclist
2021-11-19
编辑:the cyclist
2021-11-19
Matrices where the size is not predetermined cannot be defined in MATLAB. Source: this question/answer and the one it points to.
What is your use case? Maybe there is another way to do what you need.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Number Theory 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!