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

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)?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Programming에 대해 자세히 알아보기

질문:

2019년 8월 6일

편집:

2019년 8월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by