Is it possible to create a symbolic matrix whose dimensions are symbolic scalar variables?

조회 수: 1 (최근 30일)
Is it possible to create a symbolic matrix whose size is denoted by symbolic scalar variables?
Like this
syms x y
syms z [x y]
where x and y are symbolic scalar variables, and I want to create a symbolic matrix z with a size (x, y).

채택된 답변

Walter Roberson
Walter Roberson 2023년 7월 7일
편집: Walter Roberson 2023년 7월 7일
No, it is not possible in MATLAB. At the MATLAB level, symbolic arrays are plain arrays of objects, and the arrays have definite size at the MATLAB level.
For reasons I have not worked out yet, symmarray are implemented as having a fixed size even though in a sense they are scalar at the MATLAB level.
  댓글 수: 2
Zijun
Zijun 2023년 7월 7일
Thanks for your reply. Hope to see this functionality in a later version.
Walter Roberson
Walter Roberson 2023년 7월 7일
This is not going to happen for the kind of array that you used. Perhaps at some point it might be supported for symarray

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

추가 답변 (1개)

Gandham Heamanth
Gandham Heamanth 2023년 7월 7일
Hi Zijun, here is the small code on how you can create a symbollic matrix whose size is denoted by symbolic scalar variables.
syms x y;
x = 4;
y = 5;
z = sym('z', [x y]);
z = 
  댓글 수: 1
Zijun
Zijun 2023년 7월 7일
Thanks, Gandham. But if I don't know the value of x and y a priori? For example, I want to generate a file using matlabFunction:
syms x y
syms z [x y]
matlabFunction(z, 'File', 'function_z.m');
There will be a function defined in the file function_z.m:
z=function_z(x,y)
then each time I call the function, I will pass in two arguments x and y such that the size of z is dynamically dependent on x and y.
Is it possible?

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

카테고리

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

태그

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by