what is the problem?

조회 수: 2 (최근 30일)
Fatima
Fatima 2019년 11월 28일
편집: Stephen23 2020년 10월 6일
Write a program that will implement the function ?(?) = { ? 2 − 7, ? < 9 ?(? − 10), ? ≥ 10 where ? is an integer and ? ≥ 0. Using your program, graph ?(?) from ? = 0 to ? = 99 using stem().
my while loop is not under the else n>=10 what is the problem?
i=0
for n=0:99
if n<9
i=i+1
f(i)=(n.^2 - 7)
elseif n==9
f(n)=NaN
else n>=10
i=i+1
f(i)=(n-10)
while f(i)>9
f(i)=n-10
end
if f(i)<9
i=i+1
f(i)=(n.^2 - 7)
end
end
end

답변 (1개)

Andrei Bobrov
Andrei Bobrov 2019년 11월 28일
f = @(x) 2*(x - (x >= 10)*10) - 7;
  댓글 수: 1
Fatima
Fatima 2019년 11월 28일
where will i put that

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by