简体   繁体   中英

how can i hide my own function definition i.e.function m-file in matlab?

I've created my own function definition ie function m-file of for my final year project.. now I want to hide that function definition. is there any way for doing it in matlab? I want that this function m-file should become a part of my matlab compiler directories so that when I call that function from any m-file, it is called and executed, but it's function definition should not be visible to anyone.. actually I want to hide that function definition from my advisor and project evaluation committee.. I don't want that they should get any hint about that function definition... someone said it to me,"convert your m-file to c or c++ code and then add it to matlab directory. your function definition will get hide, and will also be executed when called." But I don't know how to do it? can anyone help me in doing it? I'm using matlab 7.9.0 (R2009b) please do help me, if anyone knows anything about it.. :)

There are really two parts here

  1. 'Hide' function definition
  2. Have access to a function from within a m-file

Actually there is a third I will not address or discuss further than the next line 3. Why would you hide work for a final year project from your advisor & evaluation committee


1) 'Hide' function definition

There is a built in function obfuscator called pcode (documentation)

this can be used directly on a function m-file and will create a copy of the function in the current directory with the file extension .p in which the code is 'hidden'.

Usage

pcode(foo) % foo.m is your function

2) Access to the function

The .p file will be available to any function so long as it is on the Matlab path. So simply add a folder containing the .p file to the Matlab path.

There are a few ways to do this I would personally use addpath

(alternative add the .p file to a folder already on the path)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM