Azzera filtri
Azzera filtri

importing and read data file

3 visualizzazioni (ultimi 30 giorni)
Matej
Matej il 6 Lug 2011
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. These data are the temperature values, which vary according to the sine curve (amplitude is 0.2 K, f = 0.2 Hz). My mission is to create a temperature data and tested whether program works.Problem is that I do not know how and where to create this information and how to then import into matlab(This information(data) I'm trying to create in Excel, but I do not know how the program reads the data).To test the program is enough to create some random data. 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.I don"t have this IR data
%IR Measured Temperature Data Analysis Tool
%Including data reading, drift compensation, square wave phase synchronization,
fourier analysis
format short g;
format compact;
%Read IR Data Files
clear;
name = 'IRDataFileName';
%Load multiple data files
path = strcat('D:\IRData\Folder\',name,'\');
start = 1; %First frame number
ende = 600; %Last frame number
xmax = 320;
ymax = 256;
l = floor((start-ende)+1);
m = single(zeros(ymax,xmax,l));% 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
imax = max(k);
clear s path fullname first last l i k;
pack;
%Load single data file
A=xlsread('tabela.xls');
[xmax ymax imax] = size(imgseq);
m = (permute(imgseq,[2 1 3]));
clear imgseq;
% Evaluation Area Reduction
evalareax=(1+0:320-0);
evalareay=(1+0:256-0);
m = single(m(evalareay,evalareax,:));
pack;
to avoid creating so much data, is a professor advised me to reduce the number of frames and xmax and ymax.
Looking forward to hearing form you and thank you in advance!

Risposta accettata

Fangjun Jiang
Fangjun Jiang il 6 Lug 2011
From the code, it is looking for 600 MATLAB .MAT files under the folder D:\IRData\Folder\IRDataFileName\. The files are named as IRDataFileName1.MAT, IRDataFileName2.MAT, ... IRDataFileName600.MAT. In each file, there is a matrix with the same name as the file name. For example, IRDataFileName1.MAT contains a 256 by 320 matrix called IRDataFileName1, IRDataFileName600.MAT contains a 256 by 320 matrix called IRDataFileName600.MAT.
To create those files using random data, you can use the following code. I purposely set the loop to be 3 so it will create 3 files first. If it did create 3 files successfully, you can then change the loop to be 600.
Folder='D:\IRData\Folder\IRDataFileName\';
FileName='IRDataFileName';
for k=1:3
VariableName=[FileName,int2str(k)];
assignin('base',VariableName,single(rand(256,320)));
save(fullfile(Folder,VariableName),VariableName);
clear(VariableName);
end

Più risposte (1)

Matej
Matej il 6 Lug 2011
Thanks, My question is how and where can I see values of this created arrays of data, such as IRDataFileName1.MAT, IRDataFileName2.MAT, ... IRDataFileName600.MAT
  1 Commento
Fangjun Jiang
Fangjun Jiang il 9 Lug 2011
Once you have the data file created, you can do the following in MATLAB command window.
load IRDataFileName1
whos
IRDataFileName1
plot(IRDataFileName1)
Sounds like you need to get yourself familiar with MATLAB. Follow MATLAB tutorial, there are plenty of them.

Accedi per commentare.

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by