필터 지우기
필터 지우기

matlab code file to .exe ,how to load file ?

조회 수: 4 (최근 30일)
david chuang
david chuang 2021년 2월 8일
댓글: Walter Roberson 2021년 2월 8일
When I use matlab code to compile this program, it will display please read the wav file, but when I use deploytool to generate an exe file, it will not ask me to read the wav file, and an error appears. How can I solve it?
how to read wav files on the exe file generated by matlab code?
Drag the picture to the side, there is an error message about running the exe file
thanks!

답변 (1개)

Walter Roberson
Walter Roberson 2021년 2월 8일
편집: Walter Roberson 2021년 2월 8일
  1. Do not use "clear all" in deployed code. Best is if you do not use "clear all" at all.
  2. Use uigetfile() instead of prompting for input. There might not even be an input() stream, depending how you compiled the application.
  3. Your current directory is quite likely to not be where you expect. You might want to go to the trouble of figuring out where the user's home directory is to use that as part of the uigetfile() so as to provide a reasonable default. For Windows, get the environment variables HOMEDRIVE and HOMEPATH to construct the full path to the user's home directory; for Mac and Linux, get the HOME environment variable.
  댓글 수: 2
david chuang
david chuang 2021년 2월 8일
Understanding Thank you, I would like to ask, how to read wav files on the exe file generated by matlab code
Walter Roberson
Walter Roberson 2021년 2월 8일
audioread() should work, provided that you pass in an absolute path. Make sure you use fullfile() with the directory and filename returned by the uigetfile() call. Also make sure you test that the returned filename is not numeric, as numeric indicates that the user canceled the uigetfile()
[filename, filepath] = uigetfile(....)
if isnumeric(filename)
user canceled, respond appropriately
end
location = fullfile(filepath, filename);
[audio, Fs] = audioread(location);

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MATLAB Compiler에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by