array
조회 수: 1 (최근 30일)
이전 댓글 표시
hello everybody
I would like to generate array Y=[Y1 Y2 Y3 Y4... Yn ] where n is unknown integer number and every "Y" is a column?
any help in this regard will be appreciated
댓글 수: 0
답변 (2개)
Andrei Bobrov
2012년 6월 17일
Y = eval(['[',sprintf('Y%-d,',1:n),']'])
댓글 수: 1
Walter Roberson
2012년 6월 17일
Bleh.
And besides, "n is unknown integer number", whereas your code would require it to be a known integer number at the time of execution.
Walter Roberson
2012년 6월 17일
You might be able to do this in MATLAB if you designed your own Class (Object Oriented Programming.) But you'd have a lot of difficulty working out the details because even for simple operations like assignment, MATLAB wants to be able to find out the number of elements in the variable which is something you cannot answer when n is an unknown integer.
It is tempting to suggest that you create your array of unknown width in the Symbolic Toolbox, using MuPAD operations. The problem with that is that nearly all the MuPAD array-like datatypes work with arrays of known size. I think I saw one legacy table datatype that did not require fixed array bounds in MuPAD, but I am not certain.
If you happen to have the old Maple-based symbolic toolbox, then the old "array" (lower-case "A") and "table" (not "rtable") Maple data structures can handle symbolic bounds. But if you aren't careful, you will run into contradictions...
Matters would be a lot easier if the number of columns was variable rather than unknown. If it were merely variable, then see http://matlab.wikia.com/wiki/FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Memory Usage에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!