If A
is your matrix and n
is your scalar:
A = magic(5);
n=2;
Then to manipulate (e.g. multiply by 1000
) the elements of A
that are divisible by n
, just do:
idx = mod(A,n)==0;
A(idx) = A(idx)*1000;
More Related Contents:
- To remove blood vessel [closed]
- Saving time and memory using parfor?
- How to training/testing my own dataset in caffe?
- How to concatenate a number to a variable name in MATLAB?
- Why is Matlab’s inv slow and inaccurate?
- [caffe]: check fails: Check failed: hdf_blobs_[i]->shape(0) == num (200 vs. 6000)
- Return Unique Element with a Tolerance
- Recursive Anonymous Function Matlab
- How does subplot work and what is the difference between subplot(121) and subplot(1,2,1) in MATLAB?
- support vector machines in matlab
- Shading an area boundered by a curve
- How to find all permutations (with repetition) in MATLAB?
- How can I change the color of bars in bar graph?
- Change color of 2D plot line depending on 3rd value
- How do I detect if I’m running MATLAB or Octave?
- How do I retrieve the names of function parameters in matlab?
- How to plot a circle in Matlab?
- How to show legend for only a specific subset of curves in the plotting?
- Producing subplots and then combine them into a figure later in MATLAB
- How do you use the LaTeX blackboard font in MATLAB?
- Turn a MATLAB plot into image
- MATLAB find and apply function to values of repeated indices
- Control colorbar scale in MATLAB
- How to control the margin size around subplots?
- What is the equivalent to += in Matlab?
- Indexing of unknown dimensional matrix
- Implementing anonymous functions in Fortran
- Customize dbstop in MATLAB
- How to apply a low-pass or high-pass filter to an array in Matlab?
- Remove xticks but keep xticklabels in MATLAB