How can i define a m by n symbolic matrix?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
ba sa
el 19 de Nov. de 2021
Editada: the cyclist
el 19 de Nov. de 2021
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 comentarios
Respuesta aceptada
John D'Errico
el 19 de Nov. de 2021
Editada: John D'Errico
el 19 de Nov. de 2021
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.
Más respuestas (1)
the cyclist
el 19 de Nov. de 2021
Editada: the cyclist
el 19 de Nov. de 2021
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 comentarios
Ver también
Categorías
Más información sobre Number Theory en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!