Importing data file
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, I am completely new to MatLAB. In the course of my studies I have come across a MatLAB routine, that requires to load a certain data file. I am trying to generate this data file from scratch, but dont know how.
I am attaching part of the routine that loads the data file. Could somebody please explain to how can I create a required data file.
Routine:
%Read IR Data Files
clear;
name = 'P0001';
%
path = strcat('H:\IRData\',name,'\');
start = 1; %First frame number semiinfi
ende = 300; %Last frame number
xmax = 272;
ymax = 136;
imax = floor((ende-start)+1);
m = single(zeros(ymax,xmax,imax));% Memory preallocation
for i = start:ende
fullname = strcat(path,name,int2str(i),'.MAT');
s = load(fullname);
k = round((i-start)+1); %Imageindex in array
m(:,:,k) = single(s.(strcat(name,int2str(i))));
end
clear s k path fullname start ende i;
pack;
Looking forward to hearing form you and thank you in advance!
1 Kommentar
Oleg Komarov
am 28 Jun. 2011
If you posted the first few lines of your file and the name of it (with the extension) we would be happy to help.
Antworten (1)
Walter Roberson
am 28 Jun. 2011
H:\IRData\P00011.MAT through H:\IRData\P00019.MAT
H:\IRData\P000110.MAT through H:\IRData\P000199.MAT
H:\IRData\P0001100.MAT though H:\IRData\P0001300.MAT
should all be .MAT files that contain arrays of values, each array of size 136 by 272. In any one .MAT file, the variable name used should be the same as the basic name of the file, such as P0001123 for the 123'rd file.
There is no indication here of what the values should mean.
To create the files with random data:
for K = 1:300
basename = sprintf('P0001%d',K);
S.(basename) = rand(136,272); %or appropriate data
fname = ['H:\IRData\' basename '.MAT'];
save(fname,'-struct', 'S');
clear S
end
0 Kommentare
Siehe auch
Kategorien
Mehr zu Workspace Variables and MAT Files finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!