Error Code " Struct contents reference from a non-struct array object."

% shear strain 10A_4_4_55+2_4 right cell
clc;
clear;
fileNameArray = dir('*.dat');
for i = 1:50
datStruct = importdata(fileNameArray(i).name);
a1 (:,i)= datStruct.data(1173,:);
a2 (:,i)= datStruct.data(1175,:);
a3 (:,i)= datStruct.data(1167,:);
a4 (:,i)= datStruct.data(1181,:);
a5 (:,i)= datStruct.data(1197,:);
a6 (:,i)= datStruct.data(1213,:);
a7 (:,i)= datStruct.data(1250,:);
a8 (:,i)= datStruct.data(1309,:);
a9 (:,i)= datStruct.data(1369,:);
a10 (:,i)= datStruct.data(1425,:);
a11 (:,i)= datStruct.data(1448,:);
a12 (:,i)= datStruct.data(1469,:);
a13 (:,i)= datStruct.data(1478,:);
a14 (:,i)= datStruct.data(1476,:);
a15 (:,i)= datStruct.data(1474,:);
a16 (:,i)= datStruct.data(1445,:);
a17 (:,i)= datStruct.data(1410,:);
a18 (:,i)= datStruct.data(1372,:);
a19 (:,i)= datStruct.data(1311,:);
a20 (:,i)= datStruct.data(1233,:);
end;
Please can you help me correct this code. It gives "Struct contents reference from a non-struct array object."
Thanks.

4 Kommentare

Could you provide the full copy-pasted error message and tell us what line is causing the error? It would also be helpful to see the variable values associated with that line.
Is this line below producing a structure?
datStruct = importdata(fileNameArray(i).name);
The line bellow is producing the error
datStruct = importdata(fileNameArray(i).name);
David Clement's answer moved here as a comment.
The line below is producing the error
datStruct = importdata(fileNameArray(i).name);
What is the value of
fileNameArray
% and
fileNameArray(i).name
?
Is this happening on the first loop (i=1)?

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Programming finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 6 Aug. 2019

Bearbeitet:

am 6 Aug. 2019

Community Treasure Hunt

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

Start Hunting!

Translated by