Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab 将.txt显示到文本框,无需选择_Matlab_User Interface_Path - Fatal编程技术网

Matlab 将.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

我的MatlabGUI中有一个静态文本框和按钮。我正试图在GUI中从桌面打开.txt文件到文本框

我的意思是,当我按下按钮时,我想读取文本框中的.txt文件。我不想选择文件。按下时,只需在文本框中显示txt文件

我知道这个密码-

[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');