简体   繁体   中英

Difficulty using oct2py

I recently installed oct2py along with its dependencies in order to import a few matlab functions to be used in my python code. The .m file is located in the same directory as my python code.

Could you please help me figure out, how I would import those .m files along with the methods located within them and how would I use those functions within my python code, considering that the actual functions are defined in octave/matlab. I have included an example .m file with a function

function x=readfile(y)
%  Puts the contents of a text file with path and name
%  specified in string y, into char array x.
%      Example:  mystring = readfile('c:\workdir\readme.txt');


fid = fopen(y,'r');     %  Read the Plaintext
M = fread(fid);
fclose(fid);  
x = char(M');

The above function is located in a file named 'readfile.m' within the same directory as my python code.

This is as simple as

from oct2py import octave
octave.feval( 'readfile', 'your_input_file_here.txt' )

PS. Your octave executable needs to be available from the system path.

因此,显然八度音阶4的bin中没有'octave.exe',但是八度音阶3确实如此,并且与oct2py完美兼容

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