필터 지우기
필터 지우기

How to create a symbolic matrix with unknown dimensions?

조회 수: 5 (최근 30일)
Álvaro
Álvaro 2017년 6월 27일
편집: Cam Salzberger 2017년 6월 27일
Hello,
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
  댓글 수: 1
John D'Errico
John D'Errico 2017년 6월 27일
Matrices in MATLAB don't have an unknown size. But I will point out that MATLAB does know that you transposed a variable.
syms x
x'
ans =
conj(x)

댓글을 달려면 로그인하십시오.

답변 (1개)

Cam Salzberger
Cam Salzberger 2017년 6월 27일
편집: Cam Salzberger 2017년 6월 27일
John is right that the complex-conjugate potion of the complex-conjugate transpose (') is retained. However the transpose itself is not:
f = sin(x');
subs(f,x,[1 3])
ans =
[ sin(1), sin(3)]
And nothing happens if you use the non-complex-conjugate transpose (.'):
syms x
x.'
ans =
x
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)
syms A
y = A.'*x;
You could instead do:
function y = A_transpose_times_x(x)
A = sym('A',[size(x,1),2]);
y = A.'*x;
-Cam

카테고리

Help CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by