MATLAB: Help with matrix operations, if statements

if statement

Could someone please help me with the following?
I have a 625002 x 1 double column vector filled with values that I need to multiple by a few constants. Its name is R.
For each elemental value in R, if it is less than 0.02, I would like to define a new vector S = R/0.02.
If the value of R is greater than 0.02, Id like to replace the values in S with another formula S=R*10
R = dR/R;
if R <= 0.02;
S=R/0.02;
elseif R > 0.02;
S = R*10;
end
plot (S,t);
It seems Ive got my Matlab/mathematics functions incorrect here, as I get the error:
Undefined function or variable 'S'.
Any help is appreciated
Sam

Best Answer

S = R / 0.02;
mask = R > 0.02;
S(mask) = R(mask) * 10;