app designer brining in variables from a script
3 views (last 30 days)
Show older comments
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?
Accepted Answer
Kevin Holly
on 27 Apr 2022
Edited: Kevin Holly
on 27 Apr 2022
Alex,
I have attached an app that loads Excel data as a table and then calls a live function called "TableConverter" that replaces the heading variables names of the table. When I called the function, I placed the table variable as the input. I did not use app properties. If I did choose to do this, I could call a table that is saved as a properies, such as "InputTable", into the function and then call it with "TableConverter(app.InputTable)" . Alternatively, I could place all the app's property variables into the function by with the command, "TableConverter(app). Then within the function, I could access a particular variable such as "app.InputTable".
3 Comments
Kevin Holly
on 28 Apr 2022
I wasn't sure how much manipulation was involved when converting the table. I wasn't sure how complicated the script you were using was. For instance, you may have needed to import the data as an array, tranpose the matrix, and then convert the array to a table with an array2table function. Or you might have filtered the table for certain values related to a header. Or you might have multiplied the values by let's say a thousand for it to be equilivant to another header or multiply them by a constant for unit conversion. That is why I used a switch case, to leave room for addtional changes to table.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!