How to read and operate on multidimensional cell arrays?

Hi , I am a beginer in MATLAB programming and find cell arrays confusing. I came across a code snippet that looks like
[FileNames,PathName] = uigetfile('*.txt','Select File Containing XRD Data','XRD Data.txt','MultiSelect','on');
if isa(FileNames,'double')
SpectralData = 0;
return
elseif isa(FileNames,'char')
Temp = FileNames;
clear FileNames
FileNames{1} = Temp; %FileNames is name of the file
clear Temp
end
% read in the files
Spectra = cell(size(FileNames,2),1);
disp(size(Spectra));
disp(FileNames);
for i = 1:size(FileNames,2) % i is the file number
FileID = fopen([PathName FileNames{i}]);
Temp = textscan(FileID, '%s','delimiter','');
fclose(FileID); %gets names of other files previously loaded
X = textscan(Temp{1}{1},'%f'); % parse out the 'x' values
disp(X);
X = X{1};
for j = 2:size(Temp{1},1) % j is the sample number Temp{1}=r
Spectra{i,1}{j-1,1}(:,1) = X; %creates 1-r rows , each having a spectra cell [1 1] for X and Y
disp(Spectra{1,1}{j-1,1}); %
Y = textscan(Temp{1}{j},'%f');
Spectra{i,1}{j-1,1}(:,2) = Y{1}; % save intensity information
end
end
The input file contains coordinates of points arranged as a 279*1616 matrix. Dimensions for Temp{1} is 279 * 1616 and X and Y is 1616 *1 cell
I wish to know how is Spectra created and read?
Thanks

2 comentarios

Do you have a link to that code snippet? Context for it would be helpful.
actually it's part of a GUI that reads in a file with spectral data and processes it. However, I've updated the code.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Preguntada:

el 28 de En. de 2016

Editada:

el 28 de En. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by