What is the easiest way to embed a text data file into a .m function so that you don't need two files.
조회 수: 9(최근 30일)
Guillaume 2018년 11월 1일
편집: Guillaume 2018년 11월 1일
Load your text file into a variable, however you normally read it in your code, for example:
lookuptable = fileread(yourtextfile);
Then right click on the variable in the variable browser, select 'Save As...' and in the 'Save as type' dropdown change the type from mat file to m file to let matlab autogenerate the code to create that variable.
Elias Gule 2018년 11월 1일
I guess you can store your data as part of the code. Your may create an inner function or a subfunctions that initializes your lookup table; you can also store your data as properties of a class.