Make a vector based on for loop values

1 view (last 30 days)
I need to make a code to find the number of values between 120 and 230 that are odd and are multiples of 11 and 13, then store the answers in a vector. I can't quite figure out how to make a vector based on the for loop. All I can manage to get is
n = [120:+1:230];
for n = 120:230;
if mod(2,2) == 1;
else mod(n,11) == 0 && mod(n,13) == 0;
end
end
  2 Comments
Hannah Wood
Hannah Wood on 7 Oct 2020
My teacher is requiring that we use a loop

Sign in to comment.

Accepted Answer

madhan ravi
madhan ravi on 7 Oct 2020
You are close:
if (mod(n,2) == 1)&& (mod(n,11) == 0 || mod(n,13) == 0);
If the above statement is true , you will save n in a variable.
  2 Comments
madhan ravi
madhan ravi on 7 Oct 2020
doc for % I would suggest you to do MATLAB On-ramp course

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by