combining variables into one matrix -from a single mat file, problem with struct to double conversion (getfield)

1 visualización (últimos 30 días)
I want to combine 254 files included in a single .mat file to produce a matrix 723 x 3127 x 254, with each variable being 723 x 3127. I have tried below, with help from another question I asked here:
clear all clc close all
load 'TJJ.mat'
% attempt to put all arcs together..
adata = NaN(723,3127,254);
for k=1:254
k
tic
% create the file name
filename = sprintf('TJJ_arc%03d.mat',k);
% load the data
data = load(filename);
d = getfield(data,'data');
% save the data
adata(:,:,k) = d;
toc
end
at the moment, I get an error with the getfield command. I want to convert the 1x1 struct file to double...
Can someone help me?
thanks in advance! Michael
  1 comentario
Aurele Turnes
Aurele Turnes el 5 de Ag. de 2014
The getfield function can be used to access a field in a structure, a fints object, or a vrnode object. If data is a structure, the code
d = getfield(data,'data');
is accessing the value of the field 'data' in the structure data, and is equivalent to doing
d = data.data;
This is what getfield does under the hood for a structure.
Is this what you are trying to do? What is the exact error message you are getting? You can check that data is a structure by typing class(data) in the MATLAB Command Window. You can also check that data has a field named 'data' by typing fieldnames(data) in the Command Window.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by