Matlab 将.txt显示到文本框,无需选择
我的MatlabGUI中有一个静态文本框和按钮。我正试图在GUI中从桌面打开.txt文件到文本框 我的意思是,当我按下按钮时,我想读取文本框中的.txt文件。我不想选择文件。按下时,只需在文本框中显示txt文件 我知道这个密码-Matlab 将.txt显示到文本框,无需选择,matlab,user-interface,path,Matlab,User Interface,Path,我的MatlabGUI中有一个静态文本框和按钮。我正试图在GUI中从桌面打开.txt文件到文本框 我的意思是,当我按下按钮时,我想读取文本框中的.txt文件。我不想选择文件。按下时,只需在文本框中显示txt文件 我知道这个密码- [filename pathname] = uigetfile ({'*.txt'},'File Selector'); fullpathname = strcat(pathname,filename); text = fileread(fullpathname); s
[filename pathname] = uigetfile ({'*.txt'},'File Selector');
fullpathname = strcat(pathname,filename);
text = fileread(fullpathname);
set(handles.text68, 'String' , text )
这是选择一个文件。我只想不加选择地显示
你能帮我吗?我必须为我的最后一个项目做这个
谢谢。如果您知道要显示的文本的路径例如:/home/yourname/Desktop/和文件名例如:textToDisplay.txt,您可以删除第一行中的两行,并将第三行替换为:
text = fileread('/home/yourname/Desktop/textToDisplay.txt');