Although this seems like a homework question, however, you have shown some effort, so I will explain it a bit.
The original code uses a while loop to iterate over odd numbers and sum their values. Using for loop, you don't need to increment the counter manually. For loop will automatically increment the counter with specified step-size. For example,
for counter = 1:2:value-1
end
Remember, in this case, you don't need to increment the counter variable or check the if condition rem(counter,2) == 1 inside the for loop. You just need to increment the total variable.
Best Answer