How can I run a program with support for Matlab 2013b, using Matlab 2016b?

I use Matlab 2016b on Mac OS Yosemite (10.10). The add-on products are the ones offered in the MATLAB and Simulink Student Suite.
I'm trying to run a code available on github: https://github.com/wilburtownsend/nira which has Matlab 2013b support.
After typing NIRA in the command window, waiting for the GUI to load, and clicking in the button "Find Solution" (under "Nash equilibrium"), the following error is shown:
Warning: Support of character vectors
that are not valid variable names or
define a number will be removed in a
future release. To create symbolic
expressions, first create symbolic
variables and then use operations on
them.
> In sym>convertExpression (line 1559)
In sym>convertChar (line 1464)
In sym>tomupad (line 1216)
In sym (line 179)
In simplifystruct>constraintsimplify (line 271)
In simplifystruct (line 59)
In NIRA>pushbuttonNIRA_Callback (line 620)
In gui_mainfcn (line 95)
In NIRA (line 42)
In matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)NIRA('pushbuttonNIRA_Callback',hObject,eventdata,guidata(hObject))
Warning: Support of character vectors
that are not valid variable names or
define a number will be removed in a
future release. To create symbolic
expressions, first create symbolic
variables and then use operations on
them.
> In sym>convertExpression (line 1559)
In sym>convertChar (line 1464)
In sym>tomupad (line 1216)
In sym (line 179)
In simplifystruct>constraintsimplify (line 271)
In simplifystruct (line 59)
In NIRA>pushbuttonNIRA_Callback (line 620)
In gui_mainfcn (line 95)
In NIRA (line 42)
In matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)NIRA('pushbuttonNIRA_Callback',hObject,eventdata,guidata(hObject))
Error using syms (line 155)
Cannot create a symbolic variable 'j'
by using syms inside a MATLAB
function. This can be because 'j' is
an existing function name, class name,
method name, and so on. Use sym
instead.
Error in evalinternal (line 12)
syms j pi i
Error in
simplifystruct>constraintsimplify
(line 279)
c = evalinternal(c);
Error in simplifystruct (line 59)
GAME.lessconstraints =
constraintsimplify(GAME.lessconstraints,
variables, GAME.constants,
customfunctions, periods);
Error in NIRA>pushbuttonNIRA_Callback
(line 620)
simplifystruct();
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in NIRA (line 42)
gui_mainfcn(gui_State,
varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)NIRA('pushbuttonNIRA_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
May I have any suggestions to avoid this error?
Thanks in advance

Respuestas (1)

syms j pi i
can be partly fixed by using
i = sym('i') ;
j = sym('j') ;
pi = sym('pi') ;
This will fix the i and j problem but in context will not fix the pi problem.
In context the code would want that the character vector 'sin(pi)' should be "simplified" (in some respect or other) but that pi should be treated just as an identifier and not as a special value. So for example 'sin(pi)^2+cos(pi)^2' would be expected to simply to 1 because of the general trig identity for any variable, but 'sin(pi)' should not be replaced by 0 because in context the code wants pi to be just a variable like 'sin(LeftShark)'
But this is a problem. sym('pi') is recognized by MATLAB and treated as the ineffable constant not as an arbitrary name.
So what is needed is to extract all of the names from the expression, and generate a new temporary symbolic name that is not any of them, and assign it to the variable pi, and then do the calculations, and convert back to character and then convert that name back to pi
You cannot just use
pi = sym('PI_INTERNAL_TO_EVALINTERNAL') ;
because there is a possibility that the user just *happened* to use that name. You have to find the names actually used and generate something else.
And you cannot rely on symvar to get the names, as symvar removes pi and i and names that appear to be used as functions such as the 'beta' in 'beta(x+2i)'
... or you could just decide that you do not care if the simplification transforms sin(pi) to 0.

5 comentarios

Thank you Walter for your answer, I think I understand it, and I would need to edit the code in order to eliminate the error. Nevertheless, I would like to know if is there any way to run the aforementioned code with a previous Matlab version (2013b, specifically), where
syms j pi i
is the same, or simillar to
i = sym('i') ;
j = sym('j') ;
pi = sym('pi') ;
in order to eliminate the error without editing the code.
Yes, you could use those statements to eliminate the error message about not creating j
The use of sym('pi') will not exactly match what the author of the program thought they were doing in using syms pi for the reasons I outlined above.
Thank you,
I'm sorry for my ignorance, but I wanted to know if it is possible to run a code, using the Matlab 2016b application, inside a "Matlab 2013b environment", in other words, as if I were running the code with Matlab 2013b (but only having installed Matlab 2016b). I wonder if there is a Matlab function to do that.
It is not possible to exactly emulate the behavior of a prior release. However, with careful code design you can increase the likelihood your code will run as expected on future releases.
In context the original R2013a code had a bug in the way that it treated pi. The code was trying to treat it as just another variable name, but instead it would have been treated specially as the transcendental constant.
You need to decide whether you want to be bug-for-bug compatible, or if you want the bug fixed, or if you don't care because you are not using pi.

Iniciar sesión para comentar.

Categorías

Más información sobre Graphics Performance en Centro de ayuda y File Exchange.

Preguntada:

el 1 de Sept. de 2019

Comentada:

el 5 de Sept. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by