Is it possible to define constant value in a matrix ?
Show older comments
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 Comments
James Tursa
on 23 Oct 2018
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
on 23 Oct 2018
James Tursa
on 23 Oct 2018
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
on 23 Oct 2018
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!