Why does my complied MATLAB .exe give me the same output every time I run the standalone application?
1 回表示 (過去 30 日間)
古いコメントを表示
Why does my complied MATLAB .exe give me the same output every time I run the standalone application?
The program takes in some excel data from an excel file, we do some math, then we output data back to the excel file and open it up for the user to see the output.
This program works perfect in the IDE and the output updates when I change data inside the excel file used as input, but when I make an .EXE and try the program that way, whatever the last data I had in the excel run in the IDE, is ALWAYS the output for the .exe now. Even when I change the data in the excel file and rerun.
How would I go about making this dynamic? Or have the program read in the new data from the excel file with each subsequent run?
example:
******************************************************************************
% read in some data
[num,txt,raw] = xlsread('excelFile','REPORT');
% do some math
x= 5 * num (1)
%export it back to excel file
xlswrite('excelFile',matrix,'sheet1')
%open the file up for the user
winopen('excelFile')
******************************************************************************
any and all help is greatly appreciated
0 件のコメント
採用された回答
dpb
2023 年 6 月 29 日
移動済み: dpb
2023 年 6 月 29 日
The location of file being opened isn't same in .exe as in the IDE.
Try adding a file dialog message that displays the current working directory inside the executable to see where it's actually looking for the file or
d=dir('excelFile.xl*');
fn=fullfile(d.folder,d.name)
Or, of course, you could hardcode in a specific folder if it isn't needed to ever change or use the uigetfile control to pick a file.
The use of the base file name without an extension is also problematic; what if the user changes which file format to use and then there could be multiple files which match the name; which xlsread chooses in that case isn't documented; similarly, what xlswrite chooses on output wouldn't necessarily match. You need to be much more precise in handling the file names.
xlsread and xlswrite have been deprecated; it is recommended to use readmatrix for numeric data instead.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Data Import from MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!