How to create a symbolic matrix with unknown dimensions?
18 views (last 30 days)
I would like to create a symbolic matrix of unknown dimensions. My main problem is that if I define a 1x1 symbolic variable and I transpose it, Matlab answers with the same variable (what is logical) instead of transpose(variable).
Thank you in advanced, Álvaro
Cam Salzberger on 27 Jun 2017
Edited: Cam Salzberger on 27 Jun 2017
John is right that the complex-conjugate potion of the complex-conjugate transpose (') is retained. However the transpose itself is not:
f = sin(x');
[ sin(1), sin(3)]
And nothing happens if you use the non-complex-conjugate transpose (.'):
Unfortunately, it doesn't look like there is a way to do this without explicitly specifying the size of the matrix. My advice would be to just give it as large a size as you think it may need, and then just "crop" it when you know how big it actually needs to be (whether inside this function or outside of it).
If you can give us more details on your code though, we may be able to suggest how to create the variables correctly the first time. For example, if you're writing code that does something like this:
function y = A_tranpose_times_x(x)
y = A.'*x;
You could instead do:
function y = A_transpose_times_x(x)
A = sym('A',[size(x,1),2]);
y = A.'*x;