Replacing an element in a matrix, then storing it as a different variable name

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!!

This question is closed.

Asked:

on 7 Jul 2019

Closed:

on 20 Aug 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!