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