Importing data file

4 次查看(过去 30 天)
Jernej
Jernej 2011-6-28
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 个评论
Oleg Komarov
Oleg Komarov 2011-6-28
If you posted the first few lines of your file and the name of it (with the extension) we would be happy to help.

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2011-6-28
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

类别

Help CenterFile Exchange 中查找有关 Workspace Variables and MAT Files 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by