Drag and Drop - MatLab AppDesigner
88 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I'd like to a drag and drop a file to put it on the graphic interface of an App created with the Matlab AppDesigner but I didn't find out how. The drag and drop must be from a .mat file located on my computer to an Edit Field (Text) component, in order to be then reused through the program.
Any help would be appreciated :)
Thank you in advance for your answers
2 件のコメント
採用された回答
Prof. X
2024 年 1 月 12 日
編集済み: Prof. X
2024 年 1 月 15 日
Have you seen this? It is a file drag and drop for uifigures.
I have used it with some success.
2 件のコメント
Prof. X
2024 年 2 月 29 日
編集済み: Prof. X
2024 年 2 月 29 日
It works for edit fields. I have included a sample .mat file for a test. Here is a quick script I wrote up and assuming you have the DnD_uifigure.m in your path, you will see you can drag files to the edit field and then load the data into field. Hope that helps and you have blessed day!
function TestDragandDrop
EditField = uieditfield(uifigure);
DnD_uifigure(EditField, @(EditField,File)CheckFile(EditField,File));
end
function CheckFile(EditField,File)
% Assuming your mat file has a .mat extension
[Path,FileName,Extension] = fileparts(File.names);
if strcmp(Extension,'.mat')
Data = load(File.names{:},'-mat');
EditField.Value = num2str(Data.Answer);
end
end
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Migrate GUIDE Apps についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!