Vectors must be the same lengths : <p>I want to plot angles against time. Here the code:</p>

<pre><code>clear all
close all
params.t0   = 0;     % start time of simulation
params.tend = 10;   % end time
params.m=2^8; %number of steps in each Brownian path
params.deltat=params.tend/params.m; % time increment for each Brownian path
params.R=4; % integer number to obtain EM stepsize from Brownian path stepsize 
params.dt = params.R*params.deltat; %0.01;    % time increment for both EM and ode45
params.D=0.001; % diffusion constant 
deltat= params.tend/params.m; % time increment for each Brownian path
params.D=0.1; %diffsuion 
params.R=4;
params.dt =  params.R*params.deltat; 
theta0=pi*rand(1);
phi0=2*pi*rand(1);
P_initial=[theta0;phi0];

[theta,phi]=difusion_SDE(params);
plot([0:params.dt:params.tend],[theta0,theta],'--*') 
hold on
plot([0:params.dt:params.tend],[phi0,phi],'--*') 
</code></pre>

<p>and the function file:</p>

<pre><code>function [theta,phi]=difusion_SDE(params)

dW=sqrt(params.deltat)*randn(2,params.m);
 theta0=pi*rand(1);
 phi0=2*pi*rand(1);
P_initial=[ theta0; phi0];

L =  params.m/ params.R;
pem=zeros(2,L);
Ang_rescale=zeros(2,L);
Ptemp=P_initial;

for j=1:L
   Winc = sum(dW(:,[ params.R*(j-1)+1: params.R*j]),2);
   theta=Ptemp(1); 
   phi=Ptemp(2);  

   A=[  params.D.*cot(theta);...
       0]; 

   B=[sqrt(params.D)  0 ;...
      0 sqrt(params.D)./sin(theta) ];  

   Ptemp=Ptemp+ params.dt*A+B*Winc;
   pem(1,j)=Ptemp(1); 
   pem(2,j)=Ptemp(2);


Ang_rescale(1,j)=mod(pem(1,j),pi);  
Ang_rescale(2,j)=mod(pem(2,j),2*pi);    
theta= Ang_rescale(1,j);
phi=Ang_rescale(2,j);
end
</code></pre>

<p>When I run the code, I got this message error 
    Error using plot
    Vectors must be the same lengths.
I appreciate any help to solve this error</p>
