Why does my complied MATLAB .exe give me the same output every time I run the standalone application?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuesta aceptada
dpb
el 29 de Jun. de 2023
Movida: dpb
el 29 de Jun. de 2023
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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Import from MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!