Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

mistake how can i stop

1 visualización (últimos 30 días)
Heather Erickson
Heather Erickson el 2 de Abr. de 2019
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
mistake loop needed, sorry
  1 comentario
per isakson
per isakson el 2 de Abr. de 2019
Editada: per isakson el 2 de Abr. de 2019
Homework?
mod(x,2) = 1
I think you mean
mod(x,2) == 1
See eq, ==

Respuestas (1)

Jim Riggs
Jim Riggs el 2 de Abr. de 2019
Editada: Jim Riggs el 2 de Abr. de 2019
You probably want a loop from X=100:200
Inside your loop, you select the cases you want: e.g.
for x=100:200
condition1 = mod(x,2)==1 ; % odd number
condition2 = mod(x,11)==0; % multiple of 11
condition3 = mod(x,13)==0; % multiple of 13
if condition1 && (condition2 || condition3)
% this is the one you want
end
end
  1 comentario
Jim Riggs
Jim Riggs el 2 de Abr. de 2019
use a counter to keep track of the values that you want:
count=0;
for x=100:200
condition1 = mod(x,2)==1; % odd number
condition2 = mod(x,11)==0; % multiple of 11
condition3 = mod(x,13)==0; % multiple of 13
if condition1 && (condition2 || condition3)
count=coumt+1;
A(count)=x;
end
end
At the end of this loop, "count" is the number of values stored in A.

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by