load multiple .dat files into matlab in matrix form
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a folder of N .dat files that I want to load in matrix form. They all have the filename form B000XX.dat where XX are changing. How can I accomplish this please. This code is wrong but i know it should be along the lines of this.
clear all
clc
importdata=['Cam_B_ds'];
for k=1:50
importdata=[importdata dlmread(sprintf('B000xx.dat',k))]
end
0 comentarios
Respuestas (1)
Guillaume
el 23 de Jul. de 2018
You need to read the documentation of sprintf to learn how you actually specify how data is to be inserted:
sprintf('B000%02d.dat', k)
It is very likely that your
importdata = [importdata, dlmread(sprintf('B000%02d.dat', k))]; %Added a comma for clarity
will not do what you want but you haven't really explained what you intended to do with that line. And certainly, initialising importdata with a char array as in:
importdata = 'Cam_B_ds'; %brackets removed as they didn't anything except slow the code.
is certainly wrong. No idea what the intent is behind that.
0 comentarios
Ver también
Categorías
Más información sobre String Parsing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!