Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Testing for an Integer and displaying that value.

조회 수: 2 (최근 30일)
Wesley Iv
Wesley Iv 2014년 5월 28일
마감: MATLAB Answer Bot 2021년 8월 20일
This is my task:
Write a program that accepts three parameters “lower_limit”, “upper_limit” and “factor”. The program should display all the numbers between “lower_limit” and “upper_limit” that are evenly divisible by “factor”
So I've been doing heaps of research as to why this isn't working and i've tried many different methods but I just cannot get this to work. It seems liek it should work! I've tried the mod(y,1) function. Everything. Please help. I've already tried something like this
z=floor(y)
if (z==y);
disp(num2str(y))
else
end
So that wasn't working and I just needed to have something to turn into my teacher so the following is what I've turned in:
ll=100;
ul=500;
f=5;
x=(ll:ul);
y=x/f;
if rem(y,1) == 0;
disp(num2str(y))
else
end
Any help is GREATLY appreciated. This assignment is due in 30 minutes but i would still like to know why it's not working.

답변 (1개)

George Papazafeiropoulos
George Papazafeiropoulos 2014년 5월 28일
% initial data
ll=99;
ul=500;
f=5;
% engine
lb=floor(ll/f);
if lb/2~=floor(lb/2)
lb=lb+1;
end
range=lb:f:ul;
range(2:2:end)=[];
% result
range

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by