load multiple .dat files into matlab in matrix form
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Guillaume
le 23 Juil 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 commentaires
Voir également
Catégories
En savoir plus sur Startup and Shutdown 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!