필터 지우기
필터 지우기

Drag and Drop - MatLab AppDesigner

조회 수: 53 (최근 30일)
Koussou Axel
Koussou Axel 2024년 1월 9일
편집: Prof. X 2024년 2월 29일
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
Mehmed Saad
Mehmed Saad 2024년 1월 9일
is drag and drop necessary? you can use uigetfile as an alternative
Koussou Axel
Koussou Axel 2024년 1월 9일
Hi,
Thank you for your return.
Yes, I'm aware of uigetfile, which works perfectly. However, drag and drop would be much more convenient and faster.
Regards

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

채택된 답변

Prof. X
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
Koussou Axel
Koussou Axel 2024년 2월 29일
Hi,
Sorry for my late response and thank you for your return.
This is exactly what I was looking for. However, it works with a uifigure, and I'm trying to drag and drop files must be from a .mat file located on my computer to an Edit Field (Text) component of an App.
Do you know how I can proceed?
Thank you in advance,
Regards
Prof. X
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 CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by