what is the problem?

10 vues (au cours des 30 derniers jours)
Fatima
Fatima le 28 Nov 2019
Modifié(e) : Stephen23 le 6 Oct 2020
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

Réponses (1)

Andrei Bobrov
Andrei Bobrov le 28 Nov 2019
f = @(x) 2*(x - (x >= 10)*10) - 7;
  1 commentaire
Fatima
Fatima le 28 Nov 2019
where will i put that

Connectez-vous pour commenter.

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by