How to use result of a list in matlab app designer?
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am trying to convert my program to an app; I had earlier a list that looks like this when programmed:
S={'ZnBr2'; 'MgCl2'; 'CaCl2'; 'KCl'; 'MgBr2'; 'NaCl'; 'AlCl3'; 'CH3CO2K';'HCOOK';'HCOONa'; 'CaBr2'};
str={'Choose salts available, minimum of two and maximum of three'};
result=listdlg('Promptstring',str, 'ListSize', [400,400], 'ListString', S, 'SelectionMode', 'multiple');
And then I made a list in Matlab app designer so now I think I cant use the code above to make use of the list I made in my program earlier.
Actually I have different functions that supposed to run depended on which of the salts that are chosen from the list in app 3. So I don’t know how I can call the functions, earlier I called them with ‘result’ as the input. For instance I called a function like this before , in my program:
[best_salt_1, best_salt_2, samlet_vannaktivitet,vekt_prosent_best_salt_1,vekt_prosent_best_salt_2, error]=Amongst_CaCl2_MgCl2_ZnBr2(result);
Then the function starts with checking what the result included by investigating:
if all(ismember(result,[1 2 3 ]))
I am wondering whether the program I made before starting on the apps may be useful or is not because writing programs is not the same as making apps in Matlab.?
I am attaching the apps concerned, it is mainly app3.
0 comentarios
Respuestas (1)
Cris LaPierre
el 8 de Abr. de 2023
In general, the way you program components in app designer is using callback functions. These are functions specific to a component, and they are run any time you interact with that component. Here, that would mean changing the item selected in the list.
When you change the selection, the Value property changes. You can use that to determine what item has been selected, and also use that in a conditional statement on what to do based on the selection.
When you add a callback function for this component (rt cilck > Callbacks > ValueChangedFcn), you will get a template that already extracts the Value property.
% Value changed function: ListBox
function ListBoxValueChanged(app, event)
value = app.ListBox.Value;
end
5 comentarios
Cris LaPierre
el 8 de Abr. de 2023
You may find this answer helpful for inspecting what is happening
Ver también
Categorías
Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!