![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1617598/image.png)
How do i open .hxml file in matlab gui
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Using a push button for a user input path which can be used to open and read .hxml files
my code:
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
[file,path] = uigetfile('*.hxml');
if ischar(FileName)
%disp('file selected')
eval(['!notepad++ ' PathName FileName])
else
%disp('user canceled')
end
if isequal(file,0)
disp('User selected Cancel');
else
disp(['User selected ', fullfile(path,file)]);
end
0 commentaires
Réponses (1)
Tejas
le 15 Fév 2024
I understand from your query that you are trying to open HXML file using callback to a push button.
Below is the code snippet for the callback function to push button.
function ButtonToReadHXMLPushed(app, event)
[file,path] = uigetfile('*.hxml');
if isequal(file,0)
disp('User selected Cancel');
else
disp(['User selected ', fullfile(path,file)]);
system(['notepad ' fullfile(path,file)]);
end
end
Here, replacing “eval” function with “system” function gives the desired outcome. This solution uses notepad to display the contents of HXML file. If the contents are required to be displayed in notepad++, just replace “notepad” with “notepad++” in system call.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1617598/image.png)
This solution has been tested on MATLAB R2023b. For more information about user input from file picker please refer to this documentation: https://www.mathworks.com/help/matlab/ref/uigetfile.html?s_tid=srchtitle_support_results_1_uigetfile#d126e1714445 .
For more information about the "system” function, please refer this documentation: https://www.mathworks.com/help/matlab/ref/system.html?s_tid=doc_ta#:~:text=Product%20Updates-,system,-Execute%20operating%20system .
Hope this helps!
0 commentaires
Voir également
Catégories
En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!