Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
variable limits in integration

Subject: variable limits in integration

From: Sanaa

Date: 10 Dec, 2012 09:02:15

Message: 1 of 1

Hi,
I want to integrate the discrete function a*x_n*(1-x_n) from nr to t (take r=0.005)
> > where a:0:0.001:4 and n=0,1,2,3,...., and t\in[nr,(n+1) r]
I have tried the following
% define the vector of colors, to plot the data of reach value of r in
% different color
color_vec = ['b'];
r=0.05;
for rho = 0: 0.001:10
% define the number of discrete times in interval [k*r, (k+1)*r]
n = 50;
% define the number of iterations k = 1,.....,Nit
Nit = 150;
% define the initial vector which is a vector of size n
x0 = 0.3*ones(1,n);
% define vectors x_next and x_previous
x_next = zeros(1,n); %x_(n+1)
x_previous = zeros(1,n); %x_n
time = zeros(1,n);
% initialize x_previous
x_previous = x0;
x_next = x_previous;
    hold on
for i = 1:Nit
    time = linspace(i*r,(i+1)*r,Nit);
    y_next=rho.*x_previous.*(1-x_previous);
    x_next = x_previous+ cumtrapz(y_next);
    x_previous = x_next;
 end
end
      plot(rho,x_next(1),'.', 'Color', char(color_vec))
Now I have only one point in the plot!! I also want to integrate from n*r to t!?
Any help please.
thanks a lot in advance

Tags for this Thread

No tags are associated with this thread.

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.

Contact us