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

2 vues (au cours des 30 derniers jours)
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 commentaires
Cris LaPierre
Cris LaPierre le 22 Fév 2022
How do you create FILE_NAME? What is its value?
Andrew Cuaki
Andrew Cuaki le 22 Fév 2022
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.

Connectez-vous pour commenter.

Réponses (2)

David Hill
David Hill le 22 Fév 2022
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 le 22 Fév 2022

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by