-1

Now I am new to matlab, and now the basic syntax, however I am not sure how to write a function to loop for instance the following recurrence equation:

$y(n+1)=\exp(-y(n))$

..

where $y(1) = \exp(-y(0))$

and $y(0) = x$

Gauss
  • 41

1 Answers1

1

First define $x$:

x = 1;

Next, define the vector $y$:

n = 10;
y = zeros(n,1);

Initialize the vector:

y(1) = x;

Then build a loop:

for i = 2:n
    y(i) = exp(-y(i-1));
end

To plot:

plot(1:n,y)
mzp
  • 1,925
  • 2
  • 18
  • 41