HOW TO NAME VARIABLES CONTINUOUSLY ?
이전 댓글 표시
I like to create multiple variables with different values. like A1= 5, A2 = 3, A4 = 2,....,A100 = 30.
I want all these variables separate because I have to insert these variables names in a cell array. Also, How to create separate variables with Zero values?
댓글 수: 1
Stephen23
2016년 6월 1일
@Heet: don't create variables like that, it is a slow and buggy way tow rite code. Just use indexing: this is a fast and reliable way to write code.
Beginners often think that creating variable names would be a great idea. It isn't.
답변 (1개)
댓글 수: 2
TEEH
2016년 6월 1일
@Heet: Well, you say that you need the variables in a cell array... then use a cell array. Another simple choice would be to use a structure.
Or you could actually read the page that you linked to, and you will find this sentence: "The video Optimization Modeling 2 shows how to solve the problem simply using the index numbers of the components of x."
Did you look at the video ?
Note how it uses indexing... which is much more reliable than generating variables using eval.
카테고리
도움말 센터 및 File Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!