Help with loading a data file into a GUI code
显示 更早的评论
I have a question about an operations with a GUI in matlab: I use a push button to load a data file from a folder, and the name of this file ('2DVIS_data_08_40fs') is then visualized as string in an edit text box. This is the code I use to do that:
direct_b='C:\Users\Name\Desktop\Rightfolder\';
[nomefile_b,dir]=uigetfile([direct_b,'*.*'],'Load file');
file_b=[dir,nomefile_b];
handles.file_b=file_b;
set(handles.filename_2d,'String',nomefile_b);
What I want to do is: 1) show in another edit text box just the numbers included between the last underscore '_' and the last two letters 'fs', in this case 40; 2) by changing the number in this last edit text box, I want to be able to load the data file which is in the same folder as the previous one but having the number I wrote between the last underscore '_' and the last two letters 'fs' (e.g., by loading the first one I will see '40' in the edit text box, and if I change it in the box and write '120' the program has to load 2DVIS_data_08_120fs, of course if it exists!) I solved point 1) like this:
undersc_ind = strfind(nomefile_b,'_');
fs_ind = strfind(nomefile_b,'fs');
t2fs = str2double(nomefile_b(undersc_ind(end)+1:fs_ind(end)-1));
set(handles.editbox2,'String',t2fs);
Can you help me to solve point 2) ? Thanks!
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 File Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!