Why is not working to use listbox in my case?

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

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?
From tester_app_3, I am supposed to get the result 1 when I chose to run the app with the combinations NaCl KCl ZnBr2. This result should come from the disp(app.error) statement in the app, which I have written inside the callback for 'start analysis ' button
Running tester_app_3 requires running tester_app_2 first by the way , :) it leads to tester_app_3
@Muazma Ali: In Start_analysisButtonPushed of tester_app_3.mlapp, you have:
[~, 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?
@Voss I think you have misunderstood a little bit; I placed disp (app.error) statement after the if statement for CaCl2 MgCl2 and ZnBr2 and not after NaCl KCl ZnBr2 , thats why the value of disp(app.error ) must be 1 , when I dont chose the first combination of salts..and it is not that what the app is giving me..
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])
ans = 1×3
1 2 3
find([2 7 8])
ans = 1×3
1 2 3
find([99 100001 1823746])
ans = 1×3
1 2 3
Sounds like you mean to simply do:
app.idx = index;
instead of using find there.

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su App Building in Centro assistenza e File Exchange

Richiesto:

il 21 Gen 2024

Commentato:

il 28 Gen 2024

Community Treasure Hunt

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

Start Hunting!

Translated by