I am trying to use a button to open another app window but an error keeps popping up

1 次查看(过去 30 天)
i am trying to create an app that when a button is pressed, opens up a separate app window where the user will then fill in data but when i try this code: open(FILE_NAME) this error:"File or variable name must be a character vector or string scalar" appears
  2 个评论
Andrew Cuaki
Andrew Cuaki 2022-2-22
i created another .mlapp and tried to open it using the open command, the error pops up and it redirects me but once i go back to the app it proceeds fine. i tried using this: open("FILE_NAME") and it worked with no errors but it redirected me to the editor and when id go back to the app it just terminates.

请先登录,再进行评论。

回答(2 个)

David Hill
David Hill 2022-2-22
Below shows a simple structure for what I think you want to do.
function GUI()
fig = uifigure;
p = uipanel(fig,'Position',[20 20 196 135]);
File = uieditfield(p,'Text','Position',[5 60 190 50],'Value','File Name');
btn = uibutton(p,'Position',[5 5 190 50],'Text','Open','ButtonPushedFcn', @ButtonPushed);
function ButtonPushed(~,~)
r=readmatrix(File.Value);%not sure what kind of file you are reading/opening
end
end

Cris LaPierre
Cris LaPierre 2022-2-22

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by