Create n symbolic variables
조회 수: 9 (최근 30일)
이전 댓글 표시
Hi, I would like to know if there's a way to create n differente symbolic variables (n is an input). Thank's in advanced
댓글 수: 0
채택된 답변
madhan ravi
2018년 10월 25일
편집: madhan ravi
2018년 10월 25일
EDITED
n=input('value of n?')
syms(sym('a',[1 n]))
a=(sym('a',[1 n])) %storing symbolic variables in a vector for convenience and also to use indexing
command window displays:
value of n?10
n =
10
a =
[ a1, a2, a3, a4, a5, a6, a7, a8, a9, a10]
>> a(1:6)
ans =
[ a1, a2, a3, a4, a5, a6]
>>
The above is strictly not recommended though please see http://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval
댓글 수: 9
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!