Standalone (compiled) program reading external files

12 Ansichten (letzte 30 Tage)
harry
harry am 24 Jun. 2014
Kommentiert: harry am 24 Jun. 2014
Hi,
I currently have a program running in Matlab that uses 'textscan' to read several .csv files located in the same directory as the main program and use the data it obtains from them.
When I export this as a standalone program using the Matlab Compiler I have to include these files within the "shell" of the application. Is there a way getting a compiled program to read files stored within its directory (as the "pre compiled" version did) such that when they are updated with new data the program uses this updated data?
(This is necessary as my end users need access to these csv files but do not have Matlab).
Thanks in advance.
  4 Kommentare
harry
harry am 24 Jun. 2014
filename = 'MASTER.csv';
fid = fopen(filename);
T = textscan(fid, '%s%s%s%s%s%f%f%f%f%f%f','Delimiter',',','headerlines',1,'TreatAsEmpty', '#DIV/0!');
fclose(fid);
harry
harry am 24 Jun. 2014
ahh realise those pwd and fullfile were links to help files. (Question still stands though).

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

José-Luis
José-Luis am 24 Jun. 2014
Maybe something like this:
filename = fullfile('/path/to/files','MASTER.csv');
fid = fopen(filename)
  3 Kommentare
José-Luis
José-Luis am 24 Jun. 2014
Bearbeitet: José-Luis am 24 Jun. 2014
Please accept the answer that best solves your problem.
direc = pwd
is redundant. You could do:
filename = fullfile(pwd,'MASTER.csv');
But even then, I don't really follow. If the files are in the working directory, you shouldn't need give the full path.
harry
harry am 24 Jun. 2014
yep thats a good'un

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Titus Edelhofer
Titus Edelhofer am 24 Jun. 2014
Hi,
I'm not sure I fully understood the question. If you don't add the MASTER.csv during compilation, and have a call to fopen, then fopen will look in the current folder (which is the folder where the executable is). So if you have in one folder both the .csv and the yourprogram.exe, then everything should be fine ...?
If not, add a line
p = pwd
to find out, "where" you are when running the compiled application.
Titus

Kategorien

Mehr zu MATLAB Compiler finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by