how can i convert an answer from an inputdlg into a matrix ?
조회 수: 10 (최근 30일)
이전 댓글 표시
%Attribuer des noms à des compositions reportées dans un fichier
if choice == 2
prompt = {'fichier'};
answer = inputdlg(prompt,'Fichier');
fichier = load(answer);
[nl,nc]=size(fichier);
for n = 1:nl
fichierCart = bary2cart (fichier(n,:),10);
Nom=quelleRoche(fichier(n,:)/100,Sommets_bary,Polyg,10);
hold on
x=fichierCart(2);
y=fichierCart(3);
text (x,y,Nom,'color','g','Fontsize',10);
end
end
I new to matlab so maybe my question is not formulated correctly but what i need to do is make dialog box where the user puts in a filename that contains matrix with n number of lines and 3 columns. but what my dialog box does is just give back answer with a cell that has just one box like this : answer = [file]. thank you for your help.
댓글 수: 0
답변 (2개)
Sindhu Karri
2021년 5월 12일
Hii,
Refer to below attached code,it might help you
prompt = {'Enter filename'};
dlgtitle = 'Input';
dims = [1 35];
definput = {'data.txt'}; %filename
answer = inputdlg(prompt,dlgtitle,dims,definput)
array = load(answer{1});
Hope this helps!!
댓글 수: 0
Rik
2021년 5월 12일
While you could solve it like you suggest, a much better idea (in my opinion) would be to use uigetfile.
file = uigetfile opens a modal dialog box that lists files in the current folder. It enables a user to select or enter the name of a file. If the file exists and is valid, uigetfile returns the file name when the user clicks Open. If the user clicks Cancel or the window close button (X), uigetfile returns 0.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Entering Commands에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!