create a script that add 12,5 every time a number is equal to 8 in matlab
main.m
% Create an array of numbersnumbers = [1, 8, 2, 8, 8, 4, 5, 8, 6];
% Loop through the arrayfori = 1:length(numbers)
if numbers(i) == 8 numbers(i) = numbers(i) + 12.5; % Add 12.5 to the number if it's equal to 8endenddisp(numbers)
254 chars
12 lines
This script will add 12.5 to every number that is equal to 8 in the array.