matlab - 如何从 MATLAB 获取路径?
问题描述
我想在 MATLAB 中实现一个 GUI 环境。我想使用浏览器按钮加载文件,然后将文件输入到我要使用的代码中并输出。帮助。
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(~, ~, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename, pathname] = uigetfile({'*.txt'},'File Selector');
fullpathname = strcat(pathname, filename);
text = fileread(fullpathname);
set(handles.text2, 'String', fullpathname)
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(~, ~, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename, pathname] = uigetfile({'*.txt'},'File Selector');
fullpathname = strcat(pathname, filename);
text = fileread(fullpathname);
set(handles.text3, 'String', fullpathname)
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(~, ~, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename, pathname] = uigetfile({'*.txt'},'File Selector');
fullpathname = strcat(pathname, filename);
text = fileread(fullpathname);
set(handles.text4, 'String', fullpathname)
D1=load('text2');
D1=D1';
D1=reshape(D1,l1*l2,1);
%% D2,D3 매트릭스 direct데이터 파일
D2=load('text3');
D3=load('text4');
解决方案
你用过
set(handles.text2, 'String', fullpathname)
所以在需要名称的例程中,您可以使用
get(handles.text2, 'String')
推荐阅读
- spring - GCloud 的秘密在 spring 属性中没有解决
- sql - SQL查找连接表最近30天没有记录
- regex - 仅使用正则表达式匹配末尾带有点的数字组合
- regex - bash sed 从文件末尾删除所有空格和空行
- google-cloud-platform - 将 Google Cloud Run 与 Google Compute Engine 或 GKE 连接
- ios - Swift:如何在更改标签之前完成 UIView 绘制动画
- vba - 有没有办法让 FileDialog 使用 .InitialFileName 属性打开远程计算机文件夹
- angular - Angular HttpClient 请求和 Spring Boots RestTemplate 请求之间的区别
- wordpress - 如何编辑 buddypress 页面模板
- r - 使用 dplyr 包的代码中再次出现错误