Is it possible to define constant value in a matrix ?
이전 댓글 표시
Hello,
Is it possible to have constant values in a matrix?
I mean, there are some places where the value can't change.
The problem is that I'm changing the hole matrix.
So I wonder if there is a command like:
const global pi = 3.14;
const double pi = 3.14;
Thank you
댓글 수: 4
James Tursa
2018년 10월 23일
We need more context. Can you explain what you are doing in more detail? If you mean you have a matrix of values and you want to fix one element but let the others change, then the answer is no for all of the numeric and logical and char types. You could invent your own custom class for this, but that would be a lot of work. Thus, if you explained in more detail what you are doing perhaps we could suggest other ways of doing things.
Quentin Dragomir
2018년 10월 23일
James Tursa
2018년 10월 23일
You will have to manually set these elements back to their desired states every time your code touches the matrix. If that is not feasible because something else besides your code is changing it, then you will have to find another way to solve your problem.
Quentin Dragomir
2018년 10월 23일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!