How to access Matlab search paths from mex file ?
2 views (last 30 days)
Show older comments
Hi,
I have som legacy C-code that runs as S-function within a Simulink model. Within this C-code, a text file is read using fopen. As long as the text file is located in the current Matlab directory, the file can be read successfully during simulation.
If the text file is located in some other directory which is included in pathdef.m but not the current directory, it won't be found.
Is there a way to search for the file same as 'which' would do ? All within the S-function.
Thanks in advance.
0 Comments
Accepted Answer
Jan
on 27 Mar 2014
The function mexCallMATLAB allows to run Matlab commands from the MEX file. Use this to call Matlab's which.
But I'd recommend to avoid such smart searching, because the result depends on details, the user cannot control, e.g. the order of folders inside the path and the current directory. Better rely on absolute path names to access files.
More Answers (0)
See Also
Categories
Find more on MATLAB Report Generator in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!