Whats wrong with tester_app_3?

14 visualizaciones (últimos 30 días)
Muazma Ali
Muazma Ali el 3 de Mzo. de 2024
Editada: Voss el 7 de Abr. de 2024 a las 17:26
I am not sending the functions that are needed to run the app and neither the other app required to run the app since they are many functions and the problem is in tester_app_3.
Do I need a while loop somewhere?
Seems the values for the table osmotic data aren’t saved in my table columns when I run the app?
I think there is something missing in tester_app_3 which I can’t see.
Do I need a loop to accumulate the column values in osmotic data, I just get the last value printed. It also seems that the program doesn’t start on zone nr 1 when I start the app again though I have deleted the previous files by writing the syntax delete(file).
I have matlab 2018
  8 comentarios
Muazma Ali
Muazma Ali el 19 de Mzo. de 2024
sorry probably I forgot to attach all the files that were needed.
I will try again later, :)
Muazma Ali
Muazma Ali el 20 de Mzo. de 2024
Hi again! :)
And sorry for the confusion; now all the right files for the test version are included in the zip file,
I am not pasting the description of the problem but the problems are the same as described above
Thanks for helping me

Iniciar sesión para comentar.

Respuesta aceptada

Voss
Voss el 20 de Mzo. de 2024
In order to fix the problems you're having, it is necessary to redesign the code significantly.
I gather that your intent is to run tester_app_3 for each zone, and collect the results in a single table. To do that, I made the table Osmotisk_data a property of tester_app2 (i.e., the main app), and removed the reliance on writing and reading the xls file (you can add a new button to write the file if desired).
Each time tester_app_3 is complete (by clicking on the Done button - formerly the Exit button), the zone_now property of tester_app2 is incremented so that the next call to tester_app_3 updates the correct row of the table. This was the essential logic missing in your original design.
See the attached zip containing the updated files. All mlapp files were modified, but no m files were modified.
I tried to keep your existing logic the same as much as possible, though I did add some new error-checking including disabling buttons to prevent entry into the next step with invalid parameters (and enabling them when the parameters are valid). I'm not going to claim that the program is now 100% robust, but it should be an improvement.
Some general advice for the future:
  • Do not to make a variable an app property unless it's necessary to do so. Generally it's only necessary if that variable needs to be shared among multiple apps (in which case it must be a public property) or multiple functions within one app (in which case it can be a private property). I found that most of your app properties were really only needed in one function, so those have been made into local variables in the function where they are used. You can see the list of app properties now to get an idea of the very few really necessary app properties in each app, and understand why those particular things need to be app properties.
  • Error-check and validate a variable value before storing it as an app property. It makes your programming job easier if you know your app properties are always valid (and consistent with each other).
  • In general, think about what the program needs to do when the user entered something invalid. Arguably more important than (as least equally as important as) doing the right thing when a good value is entered is not doing the wrong thing (i.e., crashing / generating an uncaught error) when a bad value is entered. In designing GUIs you have to give plenty of thought to all the bad states the program can get into, not only the one good state where everything is fine.
Let me know if you have any trouble opening the mlapp files in your version of appdesigner. Sources I've found online seem to suggest there should be no compatibility issues between R2022a (what I used to save them) and your version (R2018a or R2018b), but if there are issues, let me know.
  2 comentarios
Muazma Ali
Muazma Ali el 7 de Abr. de 2024 a las 12:14
Thanks a lot, I am now trying to understand what and how you have made the changes..
I have two questions.
Can you please explain the code in the picture that I have attached ( I didnt understand what you did here..)
In addition I am not getting the dots on my plot as I wanted to get but a line plot which I dont want
Voss
Voss el 7 de Abr. de 2024 a las 15:33
Editada: Voss el 7 de Abr. de 2024 a las 17:26
You're welcome!
Here's an explanation of that code:
% take the first zone_now rows of table Osmotisk_data from the calling app,
% and store it as local variable T for convenience:
T = tester_app3.Callingapp.Osmotisk_data(1:tester_app3.Callingapp.zone_now,:);
% put T in this app's uitable, app.UITable:
app.UITable.Data = T;
% make app.UITable column names the same as T's column names:
app.UITable.ColumnName = T.Properties.VariableNames;
% plot Osmotic_pressure vs Total_water_activity (both from table T, i.e.,
% the first zone_now rows of Osmotisk_data from the calling app) in app.UIAxes:
x = T.Total_water_activity;
y = T.Osmotic_pressure;
plot(app.UIAxes,x,y,'.-')
Change '.-' to '.' if you want to see only dots at the data points with no line connecting them. (See here for more options.)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Environment and Settings 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!

Translated by