How do I fix the error "Unexpected MATLAB Operator?"

9 visualizaciones (últimos 30 días)
Andrew
Andrew el 1 de Jul. de 2013
Unexpected MATLAB Operator when running MATLAB. After fixing the path, we still recieve the same error. This code is designed to analyze frames and calculate the RMS deviation in the Y direction.
S1= 1; % The frame on which you begin.
N1= 900; % The frame on which you end.
Nx= 30; % The x and y spread that will be cut out of the frames.
Ny= 30;
xc= 351; % One must manually find and enter the center position (xc, yc).
yc= 319;
res= zeros(N1-(S1-1),2); % Stores the position data.
spark= zeros(N1-(S1-1),1); % Creates a matrix for just Y values
count= 1; % The count of the valid pictures, starting at 1.
for framenum= S1:N1
Im= imread(sprintf('6.27.13 - 3 ~ Water _ %04d.jpeg', framenum)); % Imports the figures one by one.
im= Im(yc-Ny:yc+Ny,xc-Nx:xc+Nx); % Takes the particles out of the frame.
bwi= im2bw(im,220/255); % This is used to separate the particle from the background.
% If the background is 175, then this
% number is 200 (or you can use another
% number, but make sure this number is
% between the particle's edge
% brightness and the background's).
bwi= bwareaopen(bwi,10); %Gets rid of <10 pixel noise points.
bwi= imfill(bwi,'holes'); %If the particle shows a donut shape, fills the center hole
B= bwboundaries(bwi,'noholes'); % This gets the particle's boundary coordinates and stores
% them in a cell array. In each
% cell is a Qx2 matrix, where Q is
% the number of boundary pixels.
szB= size(B);
if szB(1)>0 % Requires that a particle be found.
s1=B{1}; % The boundary matrix of the particle
y1= mean(s1(:,1)); % The x postion of the first particle
x1= mean(s1(:,2)); % The y postion of the first particle
res(count,1)= xc-Nx+x1; % Stores the actual positions in the original picture
res(count,2)= yc-Ny+y1;
spark(count,1)=yc-Ny+y1; % Stores the Y positions in a separate matrix
xc= round(xc-Nx+x1); % Relocates the center for the next frame
yc= round(yc-Ny+y1);
end
count= count+1; % Increase the count for the next frame
end
idx= ~res;
res(idx)= nan;
Y=rms(spark); % Calculates RMS for Y values
  1 comentario
Walter Roberson
Walter Roberson el 1 de Jul. de 2013
If you run the program, is the error reported against any particular line?
You could get problems if your startup.m had invalid syntax.

Iniciar sesión para comentar.

Respuestas (1)

Image Analyst
Image Analyst el 1 de Jul. de 2013
Look in the right hand side of your editor window for the red line and click on it to go to the offending line. Then fix it. It probably has bad syntax. If you hover over the red squiggle, you may see a popup window with an offer to fix the error based on what it thinks the solution might be.
  6 comentarios
Andrew
Andrew el 1 de Jul. de 2013
Thanks. I didn't realize that the title started with a number and that it might've been the problem.
Image Analyst
Image Analyst el 1 de Jul. de 2013
Glad you found the source of the error, but in the future when we say the exact error we mean all the text that is in red, which includes the lines of code that were called as well as their line numbers - not at all what you gave in your second response when I asked you for it.

Iniciar sesión para comentar.

Categorías

Más información sobre Entering Commands en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by