MATLAB: Invalid expression…Line 16 column 48

expressioninvalid

function [x ,t,DR, DT]=homogeneous(N,dt,x0,R,T,eta,V,W)
kB=1.38e-23;
gamma=6*pi*R*eta;
DT=kB*T/gamma;
DR=6*DT/(8*R^2); x(1,:)=x0;
theta=0;
for n=1:1:N
x(n+1,:)=x(n,:)+sqrt(2*DT*dt)*randn(1,2);
theta=theta+sqrt(2*DR*dt)*randn(1,1);
theta=theta+dt*W;
x(n+1,:)=x(n+1,:) + dt*V*[cos(theta) sin(theta)];
cla
hold on
plot(x(1:n+1,1)) * 1e6;x(1:n+1,2)*1e6; 'k')
plot(x(n+1,1))*1e6;x(n+1,2)*1e6; 'o';...
'MarkerEdgeColor' ; 'k'; ...
'MarkerEdgeColor' ;'g')
hold off
axis equal square
title(['velocity= ' num2str(V*1e6) '\mum/s,' , ...
'angular velocity= ' num2str(W) 'rad/s,' , ...
'time= ', num2str(dt*(n+1)) 's'])
xlabel('x[\mum]')
ylabel('y[\mum]')
box on
axis equal
drawnow();
end
t=[0:dt:(N-1)*dt];

Best Answer

You have a closing parenthesis too early:
plot(x(n+1,1))*1e6;x(n+1,2)*1e6
% ^
Also, you should use commas to separate arguments instead of semicolons.
Additionally, it does not make sense to use cla inside the loop. If you want to show only 1 plot, you should update the XData property instead of clearing the axes. You should also move the calls to title etc to outside the loop.