Error using fileparts with Datastore

11 visualizaciones (últimos 30 días)
Bartholomäus Jan Rebmann
Bartholomäus Jan Rebmann el 9 de Dic. de 2021
Comentada: Bartholomäus Jan Rebmann el 10 de Dic. de 2021
I found an official Matlab tutorial on youtube and tried to rebuild it, but i got a Syntax Error and don't know how to solve it.
The link to the tutorial: https://youtu.be/K-ob5DIfE7U
My Code so far
So my question: how can i solve this Error? Why is it working in the Video?
Thank you in advance!
Greetings
B. Rebmann

Respuestas (2)

Jan
Jan el 9 de Dic. de 2021
Try:
[~, filenames] = fileparts(cellstr(ds.Files))
But actually this should work. Which Matlab version are you using? spreadsheetDatastore was introduces in R2016a. I do not remember if fileparts worked with arrays in this version. If not, create your own function to do this:
function [Folder, File, Ext] = filepartsX(FilePath)
FilePath = cellstr(FilePath);
Folder = cell(size(FilePath));
File = cell(size(FilePath));
Ext = cell(size(FilePath));
for k = 1:numel(FilePath)
[Folder{k}, File{k}, Ext{k}] = fileparts(FilePath{k});
end
end
  1 comentario
Bartholomäus Jan Rebmann
Bartholomäus Jan Rebmann el 10 de Dic. de 2021
Thank you!
The first solution didn't help, but with the second one i could run the script.
Thank you very much!

Iniciar sesión para comentar.


Steven Lord
Steven Lord el 9 de Dic. de 2021
I believe ds.Files returns a cell array or a string array of file names. Support for a cell array of file names or a string array of file names in fileparts was introduced in release R2020b as stated in the Release Notes.
  1 comentario
Bartholomäus Jan Rebmann
Bartholomäus Jan Rebmann el 10 de Dic. de 2021
Alright thank you, then it is probably my version. Thank you

Iniciar sesión para comentar.

Categorías

Más información sobre Introduction to Installation and Licensing en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by