How to add a .mat file (including the file path) to a specific location in a Python script and save this Python script using matlab?
3 次查看(过去 30 天)
显示 更早的评论
Is it possible to add a .mat file location to a specific location in a Python script and save this Python script using MATLAB
0 个评论
采纳的回答
Kenny Shu
2018-8-28
You can write directly to the Python script using "fprintf":
replaceLine = 2
fid = fopen('mypyfile.py', 'r+');
for k=1:(replaceLine-1);
fgetl(fid);
end
fseek(fid, 0, 'cof');
fprintf(fid,'print("%s")','myMAT.mat')
fclose(fid)
Refer to the following link for additional information on writing data to text files:
Consider writing the MAT file location to an intermediate medium (such as a text file or database) in MATLAB and reading from that medium in Python.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Call Python from MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!