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

problem with running some codes in http://www​.mathworks​.com/matla​bcentral/f​ileexchang​e/36321-de​mo-finding​-an-optima​l-path-usi​ng-matlab-​and-optimi​zation-too​lbox

Asked by Hoda on 16 Aug 2013

Hello every body I downloaded but when I run the PathOptimizationDemo.m the below error is displayed:

??? Error: File: PathOptimizationDemo.m Line: 217 Column: 27 Unexpected MATLAB operator.

can anybody help me ASAP? Thanks in advance




No products are associated with this question.

1 Answer

Answer by Walter Roberson on 16 Aug 2013
Accepted answer

Which MATLAB version are you running?

I suspect you are using a MATLAB version old enough to not know about using ~ as a placeholder.

Replace lines that look like

function NAME(~,~,variable1,variable2)


function NAME(TMP___1, TMP___2, variable1, variable2)

where TMP___1 and TMP___2 are arbitrary variable names that are not used inside the function.


Hoda on 16 Aug 2013

That's true my matlab version is old,thanks alot;but I can't still run it:another error: ??? Undefined function or method 'rng' for input arguments of type 'char'.

Error in ==> PathOptimizationDemo>pushbutton_NewField_Callback at 97 rng('shuffle');

Error in ==> PathOptimizationDemo>PathOptimizationDemo_OpeningFcn at 72 pushbutton_NewField_Callback(hObject, eventdata, handles)

Error in ==> gui_mainfcn at 221 feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure), varargin{:});

Error in ==> PathOptimizationDemo at 48 gui_mainfcn(gui_State, varargin{:});

what should I do about it?

Walter Roberson on 16 Aug 2013

Unless your version of MATLAB is older still, in which case you might need to use state()

Hoda on 16 Aug 2013

sorry ,Ididn't umderstand.what should I do exactly,I can't install newer version now.the version is 7.8.

Walter Roberson

Contact us