Why is not working to use listbox in my case?
Mostra commenti meno recenti
The problem :
This is a much much simpler version of my app three that I have called for tester_app_3.
When I write disp(app.error) before if app.error==1 in tester_app_3, it does not give me the right value though it is set to be right in the functions. The value of error is just set in the combinations’s functions CaCl2_MgCl2_ZnBr2 and NaCl2_KCl_ZnBr. The other functions just compute some other values
In other words the program is not going further to the combinations I chose. Thats why it gives me the value of app.error to be ==0
I have called the simpler version of my app3 as tester_app_3, reduced the app to be much smaller than it was by removing many functions from CaCl2_ MgCl2_ ZnBr2 and NaCl_KCl_ZnBr2 and letting the smaller functions remain a part of the functions. The only big functions that I have included are the two combinations functions CaCl2_ MgCl2_ ZnBr2 and NaCl_KCl_ZnBr2 and beregn_ionic_strength_best_salts_NaCl_KCl_ZnBr2 and beregn_ionic_strength_best_salts_CaCl2_MgCl2_ZnBr .
ONLY THE CaCl2_ MgCl2_ ZnBr2 and NaCl_KCl_ZnBr2 are relevant for the problem ( I had to adjust the code within these functions so that I didnt need to attach too many functions :).
Kindly help me with my problem.
5 Commenti
Benjamin Thompson
il 21 Gen 2024
Can you provide more information about where the problem is happening in your code? Which line of which file? When you use the MATLAB debugger to step through it what result are you getting? What result do you expect to get at the line where the problem occurs?
Muazma Ali
il 21 Gen 2024
Voss
il 21 Gen 2024
[~, index] = ismember(app.ChooseminimumtwosaltsandmaximumthreesaltsListBox.Value, app.ChooseminimumtwosaltsandmaximumthreesaltsListBox.Items);
which produces index = [1 4 6] when NaCl, KCl, and ZnBr2 are the only selections.
Then the next line
app.idx = find(index);
produces app.idx = [1 2 3]
You pass app.idx to Amongst_CaCl2_MgCl2_ZnBr2_test, which immediately checks whether all elements are 1, 2, or 3 and assigns error=0 in case they are:
if all(ismember(idx,[ 1 2 3]))
error=0;
All elements of [1 2 3] are 1, 2, or 3, so why do you expect error will be anything other than 0?
Muazma Ali
il 28 Gen 2024
You think that you have written the program so that "the value of disp(app.error ) must be 1 , when I dont chose the first combination of salts", but that's not what the program is doing.
As I explained before, when index is [1 4 6], then the following line gives app.idx = [1 2 3]
app.idx = find(index);
In fact a selection of any three salts gives app.idx = [1 2 3]. Look:
find([1 4 6])
find([2 7 8])
find([99 100001 1823746])
Sounds like you mean to simply do:
app.idx = index;
instead of using find there.
Risposte (0)
Categorie
Scopri di più su App Building in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!