undefined variable, passive variable vector

HELLO do you know how should i make vector with passiv variable.and be aware of that the size of this vector will be defined in the middel of program. thanks

댓글 수: 1

David Young
David Young 2011년 3월 1일
Please would you delete the four duplicates of this question. Thanks.

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

 채택된 답변

Walter Roberson
Walter Roberson 2011년 3월 2일

1 개 추천

See the documentation for sym and in particular this part:
A = sym('A', [m n]) creates a m-by-n matrix of symbolic variables. The dimensions m and n of a matrix must be integers. You can use this syntax to create a 1-by-n or an n-by-1 vector. The sym function does not allow you to use symbolic variables without assigned numeric values as dimensions. By default, the generated names of elements of a vector use the form Ak, and the generated names of elements of a matrix use the form Ai_j. The base, A, must be a valid variable name. (To verify whether the name is a valid variable name, use isvarname). The values of k, i, and j range from 1 to m or 1 to n. To specify other form for generated names of matrix elements, use '%d' in the first input. For example, A = sym('A%d%d', [3 3]) generates the 3-by-3 symbolic matrix A with the elements A11, A12, ..., A33

댓글 수: 3

kaveh
kaveh 2011년 3월 3일
thank you very much,i never forget your help;-)
kaveh
kaveh 2011년 3월 3일
sorry for disturbing you again
i write as you said but i got this error:
??? Error using ==> sym.sym>char2sym at 414
Not a valid symbolic expression.
Error in ==> sym.sym at 95
S = char2sym(x);
Error in ==> Untitled at 4
A=sym('A%d%d', [4 3] );
>>
Walter Roberson
Walter Roberson 2011년 3월 3일
I do not know which version the ability to use a format with sym() came in. Which version are you running ?

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

추가 답변 (2개)

David Young
David Young 2011년 3월 1일

1 개 추천

In MATLAB, you probably don't need to make the vector before you know its size. You don't have to declare variables, so the best solution is probably to simply not use the vector until the point where the size is known.
If there's some reason you need to reference the variable before that point, you could set it to the empty matrix:
v = [];
to indicate that it's a vector with, as yet, no contents.

댓글 수: 3

kaveh
kaveh 2011년 3월 1일
sorry ,i think i Express bad my question.
i mean:
i need vector for exampel [x1 x2 ... xn]
to multiplication it to another matrix
then i have matrix with arrays that have Unknown variable and i have some equation in every line of answer matrix
David Young
David Young 2011년 3월 2일
Can I just check - are you asking about the Symbolic Math Toolbox, as Kaustubha govind suggests? If you are, then sorry, I misunderstood. I don't know about that toolbox, and I hope someone else can help.
kaveh
kaveh 2011년 3월 3일
no i just ask for matlab program,but any way thanks for your care;-)

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

Kaustubha Govind
Kaustubha Govind 2011년 3월 1일

1 개 추천

I think you need the Symbolic Math Toolbox.

댓글 수: 1

kaveh
kaveh 2011년 3월 3일
thanks i think my problem is solve by WALTER suggestion,but thanks for your care you have;-)

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

카테고리

Community Treasure Hunt

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

Start Hunting!

Translated by