Thread Subject:
Index exceeds matrix dimensions

Subject: Index exceeds matrix dimensions

From: Sanaa

Date: 1 Jun, 2012 19:51:08

Message: 1 of 3

Hi,
I am plotting the trajectories of the map
x(t) = 1- ru*x(t-1)^2

using the code


function out = traj(fun,x_init,ru,max_iter,r,t_step)
% % example
% % figure;fun = @(x,r) 1 - r*x*x;out = traj(fun,.4,0.5,150,1,100);

out = zeros(ru,max_iter);
%ru_vec = linspace(ru_start,ru_end,ru_steps);
format long

    for j = 1:max_iter
% if j == 1
         x_0 = x_init;
% end
        t = linspace(r*j,r*(j+1),t_step);

         for k = 1:length(t)
% if k == 1
% x_0 = x_init;
% end
           x = fun(x_0,ru);
           x_0 = x;
% out(j,k) = x;
         end
        x = fun(x_0,ru);
        out(j) = x;
        x_0 = x;
% plot(repmat(ru,1,length(out(:))),out(:),'b.','linewidth',2);
% hold on;
    end
% plot(repmat(ru,1,length(out(:))),out(:),'b.','linewidth',2);
    plot(repmat(1,length(out(j,:))),out(j,:),'.','linewidth',1);
    hold on;
end

I get the error
Index exceeds matrix dimensions

any help please

Subject: Index exceeds matrix dimensions

From: Matt J

Date: 1 Jun, 2012 20:48:07

Message: 2 of 3

"Sanaa" wrote in message <jqb6fc$3k7$1@newscl01ah.mathworks.com>...
>
> I get the error
> Index exceeds matrix dimensions
>
> any help please
================

The error message should also have told you at what line number the error occurred. Stop the code at that line using DBSTOP or by setting a break point there. Then examine the value of the indices used at that line to see if they are illegal.

Subject: Index exceeds matrix dimensions

From: reza

Date: 1 Jun, 2012 22:27:32

Message: 3 of 3

On Jun 1, 4:48

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
debugging skills Matt J 1 Jun, 2012 16:49:11
rssFeed for this Thread

Contact us