필터 지우기
필터 지우기

Calculating values from an iterative map

조회 수: 2 (최근 30일)
Ollie
Ollie 2015년 8월 13일
편집: Ollie 2015년 8월 13일
I need to write a Matlab code that will calculate the x10 value for the following iterative map that doesn't use fsolve,\ or inv commands, given x0= -3.
I also need a code that will calculate:
for the same iterative map.
Any help would be very appreciated :)
  댓글 수: 1
Ollie
Ollie 2015년 8월 13일
Thanks, I think I understand how to do the first part now although I am still struggling with the second part. Is there anyone who could give me the specific code to program it?

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

답변 (2개)

Walter Roberson
Walter Roberson 2015년 8월 13일
Use a "for" loop. Inside the "for" use "if" and "elseif".
  댓글 수: 2
Walter Roberson
Walter Roberson 2015년 8월 13일
x(1) = 0;
for n = 1 : 10
xn = x(n);
first_expression = some calculation with xn
second_expression = some other calculation with xn
if first_expression < second_expression
xn1 = some result calculated with xn
else
....
if third_expression < fourth_expression
...
xn1 = ...
else
...
xn1 = ....
end
end
x(n+1) = xn1
end
Ollie
Ollie 2015년 8월 13일
편집: Ollie 2015년 8월 13일
Thanks for the reply. This is the code I have attempted:
x(1)=-3;
for n = 1:10
xn = x(n);
expression1 = xn^4 + 8;
expression2 = 1/(xn*sqrt(abs(xn)));
expression3 = 3 - xn^2;
if expression1 <= expression2
xn1 = sqrt(abs(xn)) - 3*xn
else
if expression3 <= expression2
xn1 = -1/xn*tan(xn)
else
xn1 = -3/xn
end
end
x(n+1)=xn1
end
The code is not returning the correct result. Can you tell me how to fix it?

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


Purushottama Rao
Purushottama Rao 2015년 8월 13일
for the second part,
s=0;
for n=4:8
k=(x(n-1)-2)+(x(n-1)+1);
s=s+k;
end
disp(s)

카테고리

Help CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by