New load error (must be string scalar or character vector) in data collecting code

26 vues (au cours des 30 derniers jours)
I am using an extensive set of functions my team and I have built that essentially looks in a folder, collects all of the necessary files (with extensions like .mat, .csv, and .txt) that we need. All of the files of interest are in one folder, easy to access, and the outcome of the code is the highlighted bit. For the below picture, the code worked (from February 3, 2020.)
However, when using data from a different date (different folder, but same exact format with same type of files other than the final highlighted file being absent), the code does not work. Below is the file setup that I loaded into Matlab via the function.
(No difference in setup, other than some files being larger in size.)
The following is the error message I receive. I think the problem I am encountering is that the function is not able to load in the .csv file called ttlDATA (located outside of both of the pictures folders, in one SINGLE location.) Therefore, it is undefined and can't collect any components from it, which contribute to the later errors in lines 97 and 220 (shown.)
This is the overall error message, referencing an inability to load the file needed for the command we named MATlist and MAT_list (from the ttlDATA.csv that is accessible to the program.
This is line 97, where it uses components within the ttlDATA.csv to compile data of interest.
This is line 220, where it uses the same extracted data from line 97 to further organize it.
**I have checked that the added paths and the file directory in the function align as they did with the February 3, 2020 file which had NO PROBLEMS.
Where could my problem lie? All variables are the same; I have not changed the code at all; only which files it is accessing. I have tried restarting the program, adding/deleting paths so that it can re-recognize it, ensuring that elements of the problematic file can load onto Matlab (they can, via load('file'). How do I fix this error?
Thank you very much.
  4 commentaires
Walter Roberson
Walter Roberson le 3 Juil 2020
Could you confirm that at the time the problem occurs, that class(inMATlist) is char and size(inMATlist) is 1 x 1 ?
It is not an error to load a file whose name is given as a single character: it would first look for a file with that exact name and would then look for the name followed by '.mat'. You might get a message about the file not being found, but you would not get a message about must be string scalar or character vector.
I am a bit confused, though, about whether it is the .mat that you are having trouble reading, or if it is ttlDATA.csv that you are having trouble reading, or if reading ttlDATA.csv is returning back content that you are not expecting?
Which release are you using? And is it possible that ttlDATA.csv has UTF encoded bytes but that you are using a release before R2020a ?
Sunderland Baker
Sunderland Baker le 4 Juil 2020
Hi; this is a problem on the behalf of my files that were collected in the code; not the code itself. But, again, thank you so much for the insight!

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Programming Utilities dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by