MATLAB Answers

0

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

Asked by David Clement on 6 Aug 2019
Latest activity Edited by Adam Danz
on 6 Aug 2019
% 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 Comments

Show 1 older comment
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)?

Sign in to comment.

0 Answers