|
Dear varun dj!
> I tried to use getcwd in S-Function but its not working...
> What should be done in S-Function to know its current working directory...
GETCWD does reply the "current working directory". But this is, as the name says, the directory, which you are currently working in, and *not* the parent-directory of the currently processed function!
I'm not using Simulink, so perhaps my idea does not work. But inside Matlab, the function WHICH can find a file by its name and searches also in the folder of the currently processed function. In addition FOPEN(FileName, 'r') searchs in the entire Matlab path also - even if the FileName includes a path! So you can omit the pathz and find the file!
By the way: FOPEN(FileName, 'r+') does not dig in all folders of the PATH, therefore it is much faster! (At least under Matlab 6.5, 7.7, Windows)
Finally I'd strongly recomment to split functions and data and store the data in a neutral folder, e.g. PREFDIR or TEMPDIR. Then your program does not depend on volatile folder names.
Kind regards, Jan
|