Help with Matlab homework question
Afficher commentaires plus anciens
𝑋𝑛+1 = 𝑋𝑛 2 + 0.25
Considering the relation, calculate and record the value of the relation for each value of n,
Write a computer program that will output the result for only n = 0, 5, 10, 15,… values.
n = 0,1,2,3,…., N
N=54
4 commentaires
David Hill
le 24 Mai 2021
What have you done? You need a starting value of X at some point, for example X(12)=5 or X(0)=1.
polat kayhan
le 24 Mai 2021
polat kayhan
le 24 Mai 2021
Image Analyst
le 25 Mai 2021
There is something missing between the n and the 2.
Do you mean x(n+1) = x(n) * 2 + 0.25 or what????
n = 0 : N
x(1) = 0;
for k = 2 : length(n)
index = n(k) + 1; % Index can't start at 0. It needs to start at 1.
x(index + 1) = x(index) * 2 + 0.25;
end
x % Show x for all values of n in command window.
Réponses (2)
Sulaymon Eshkabilov
le 24 Mai 2021
0 votes
Use colon operator ":" to generate the series of x(n+1). And to select or take out only n = 0, 5, 10, 15,…54 values, use again ":", e.g. 1:5:54
Good luck.
1 commentaire
polat kayhan
le 24 Mai 2021
Sulaymon Eshkabilov
le 24 Mai 2021
What you are computing is not quite correct. But you have done some attempt.
Here is a simple solution
n = 1:54;
x(1)=0;
for ii = n
x(ii+1)=x(ii)^2+.25;
end
X_out = x(1:5:54);
OUT = [(0:5:54);X_out];
fprintf(' n Output: \n')
fprintf('x(%d) = %f \n', OUT)
2 commentaires
polat kayhan
le 24 Mai 2021
Sulaymon Eshkabilov
le 24 Mai 2021
Modifié(e) : Sulaymon Eshkabilov
le 25 Mai 2021
So what?
Catégories
En savoir plus sur Mathematics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!