Figure open on every run
Mostrar comentarios más antiguos
Hello i want my figure only open once and not on very new compile. I send the code but it still opens everytime i click run. I added the if equations but it didnt changed: Can you pls help me?
if ~exist('fig', 'var') || ~isvalid(fig)
fig = uifigure('Name', 'test', 'Position', [300, 300, 800, 600]);
% UI-Komponenten erstellen
layout = uigridlayout(fig, [1, 2]);
label1 = uilabel(fig, 'Position', [20, 500, 300, 60], 'Text', ['hello'],'FontWeight', 'bold');
label2 = uilabel(fig, 'Position', [130, 500, 300, 60], 'Text', ['hello'],'FontWeight', 'bold');
layout.ColumnWidth = {'1x', '1x'};
label3 = uilabel(fig, 'Position', [20, 350, 300, 60], 'Text', ['hello']);
label4 = uilabel(fig, 'Position', [20, 320, 300, 22], 'Text', ['hello']);
end
2 comentarios
Manikanta Aditya
el 25 de Mzo. de 2024
Hi,
I think the issue is mostly due to the scope of fig variable. If you’re running this code in a function, the fig variable is local to that function. This means that every time you run the function, it doesn’t know about the fig from the last run.
max muster
el 25 de Mzo. de 2024
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!