Dealing with v(end+1) when v(1) may not have been defined
조회 수: 1 (최근 30일)
이전 댓글 표시
I use the following kind of construction a lot
v(1) = (x+y)^2;
v(end+1) = (x^2 + 2*x*y + y^2)
etc. Sometimes v would be a vector of symbolic expressions, sometimes they are numeric.
I'd like to be able to initialize v in some way so that I could begin with
v(end+1) = (x+y)^2
and thus not treat the first element of the array in a special way.
I.e., I'd like to be able to do something like
v = ''
v(end+1) = (x+y)^2;
v(end+1) = (x^2 + 2*x*y + y^2)
But this doesn't work. Is there a way to do this?
Thanks for any suggestions.
댓글 수: 0
채택된 답변
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!