Is there a way to create PCODE files that are intended for use in a specific MATLAB release?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am working with PCODE files in different MATLAB Releases and I need to make small adjustments to my files according to each version for compatibility reasons.
Now after converting my files to PCODE I need to have the possibility to detect which MATLAB version the file is intended for. I don’t know how to do this, as the files are obviously having the same name and there seems to be no version information in the files after calling PCODE.
Respuesta aceptada
MathWorks Support Team
el 17 de Mayo de 2011
PCODE files (like MATLAB files) do not automatically hold any version information. If you are designing your code in compliance to a specific MATLAB release you could just add this information directly in the MATLAB code and use an additional input parameter to be able to gather this information from the PCODE file.
A simple way to design this can be implemented using VARARGIN as in the following example
function y=myfun(x1, x2, varargin)
if size(varargin,2) >= 1 & strcmp('version',varargin)
disp('MATLAB VERSION') % fill in specific version hier
return
end
%myfun code goes here
y=x1+x2;
Now after using PCODE on myfun.m you can use it’s actual functionality and query the version information you have included:
>> myfun(1,2)
ans =
3
>> myfun([],[],'version')
MATLAB VERSION
0 comentarios
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!