Info
This question is closed. Reopen it to edit or answer.
Replacing an element in a matrix, then storing it as a different variable name
1 view (last 30 days)
Show older comments
Hello!
I am having a hard time replacing an element in a matrix and then being able to rename the new matrix with the replaced values.
For example:
I use
x=[1 2 1; 3 4 3; 5 6 5]
I want to replace all the '3' with '4' AND be able to call the solution x2
I know that I can replace elements with the equation
x(x==3) = 4
but that changes the values in x
I want to create a new matrix with the replaced values as 'x2'
I keep running into the problem of not being able to use "=" more than once in a line of code.
Help is much appreciated!!
0 Comments
Answers (1)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!