Problem importing files-- matlab version changes
Akzeptierte Antwort
Weitere Antworten (3)
While unfortunately may not return to see it; I took a little time and recast the function to reduce the duplicated code and clean up the many orange lines the ML editor complained about in the original...a great number having to do with not preallocating arrays and augmenting them in loops. Without getting carried away with generic names; simply reducing the branching to near-minimal for the difference between input variables in mph vs kph and using array syntax instead of loops I cut the file length from approx. 630 lines to 330 (including the 25-30 lines of additional comments added) or less than half in actual code.
Incorporated categorical for the variables R2017b wanted to turn into them as well as including the fixup on the time parsing as noted. Results are the same. ( ERRATUM The earlier note about one variable being different was an error on my part in dropping a factor of 10 in the length of input vector for decimation so the previous results were based on 1:4 instead of original 1:1. Fixed in the attached script.)
If one were to further factor the code into functions to calculate the basic results and pass the appropriate data to them and return the results in arrays instead of named variables for every variation, one could probably cut the amount of code by nearly half again.
NB: I defined a variable DATALOADED to keep from having to go thru the early preambles every time while testing once the file had been imported once by setting
clearvars; DATALOADED=false; prac
or after a run that did load
DATALOADED=true; prac
that let me work piecewise through the sections without having to mess with loading the data every time if didn't need a fresh copy. You can just delete or comment out that IF...END block if don't want it.
I tried to figure out a more user-friendly way to pause the script so don't have the refocus thingie, but none of the UI message boxes with UIWAIT() seemed to work correctly with the UIIMPORT window. There's probably some way but I'm not a GUI-type guy; that's out of my league.
Hopefully this can help some; I do think there were/are some issues in the original posted that need to be fixed but don't have any way to directly pass them on; best I can do is this.
0 Stimmen
1 Kommentar
22 Kommentare
Kategorien
Mehr zu Tables finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

