app designer brining in variables from a script
Afficher commentaires plus anciens
Hopefully I can explain this:
I am working on an app where the user can load in csv files. The csv files are vehicle data from CANbus and so naturally, different vehicles can have different header names for the same thing like vehicle speed. The data are read in using readtable, so normally in my typical matlab script, the data comes in as a table.
So my idea was, once the user had loaded in the vehicle data. They would then load in a script file that contained the right mappings. So what I am trying to do is map the differing names to some standard names that can then be used throughout the app.
But I am a bit stuck on how you actually get them in. I know you can use run() to run the script, but obviously you can't see the variables.
would I add my standard names in the app as properties first? so for example: app.VehicleSpeed.
Then in the script i have app.VehicleSpeed = app.importedfile.CANbus_name?
2 commentaires
Kevin Holly
le 26 Avr 2022
Modifié(e) : Kevin Holly
le 26 Avr 2022
You could turn the script into a function MATLAB file and call it with the variables you need as the inputs. Also, run() is not needed to run your script. You could just type the name of the script.
For the function inputs, you do not need to use the app's property variables. If the function is called within one of the app's callback function and all variables are in that callback's workspace, then you just simply input the variables into the function. If you want to use properties variables as inputs, you could use them as inputs to the function as a single variable (app.variable) or as a structural array (app), which you can use to call all the app's properties within your function. Let me know if you would like me to provide an example.
Alex Mason
le 27 Avr 2022
Modifié(e) : Alex Mason
le 27 Avr 2022
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Text Data Preparation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!