Skip to content

Instantly share code, notes, and snippets.

@tmwatchanan
Created June 4, 2016 14:32
Show Gist options
  • Select an option

  • Save tmwatchanan/3d84ac4023bacc1aaacd75ce98060769 to your computer and use it in GitHub Desktop.

Select an option

Save tmwatchanan/3d84ac4023bacc1aaacd75ce98060769 to your computer and use it in GitHub Desktop.
MATLAB script – any members in array A that greater than 5 will be changed into 5
A = [2 5 7 0 3 2 1 8 9]
for k = 1:length(A)
if A(k) <= 5
B(k) = A(k); % insert ; to disable internal message of this step
else
B(k) = 5; % insert ; to disable internal message of this step
end
end
disp(B) % display the value of B
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment