Attempt to reference field of non-structure array.

I have many files, which are made as a loop, each one has two columns with text line, I want to draw the map for it by this script. but I faced this problem ' Attempt to reference field of non-structure array'.
clear xstep=18; %number of x steps
ystep=34; %number of y steps
map0V = zeros(ystep+1, xstep+1);
data0V = zeros((ystep+1)*(xstep+1),3);
for j=0:xstep;
for i=0:ystep;
filename = strcat('Read330uW_S5_Bg0VLoop1_',int2str(j), 'Loop2_', int2str(i), '.dat');
scana=importdata(filename);
rowa=scana.data(:,end);
map0V(end - i,j+1)=2.22.*mean(rowa(2:end))/1E5;
% rearrange matrix for origin plotting
data0V(j*(ystep+1)+(i+1),1) = j-2; % x co-ords in 1st col
data0V(j*(ystep+1)+(i+1),2) = i; % y co-ords in 2nd col
data0V(j*(ystep+1)+(i+1),3) = map0V(end - i,j+1); % Ipc value in 3rd col
end
end
%plot 'map matrix'
figure;
pcolor(-2:23, linspace(12,0,13), map0V);
axis equal;
caxis([-2E-10,2E-10]);
colorbar
% Create colormap that is blue for negative, red for positive, % and a chunk inthe middle that is black.
redColorMap = [zeros(1, 128), linspace(0, 1, 128)];
blueColorMap = [linspace(1, 0, 128), zeros(1, 128)];
colorMap = [redColorMap; zeros(1, 256); blueColorMap]';
colormap(colorMap);
% shading interp; %labels
title('Graphene Photodetector Vsd=0V');
xlabel('X (\mu m)');
ylabel('Y (\mu m)');
%get white coordinate lines
grid on;
% set(gca,'XColor','w',... % 'YColor','w') % set(get(gca,'XLabel'),'Color','w') % set(get(gca,'YLabel'),'Color','w')
%save matrix
dlmwrite('Graphene Photodetector_Photomap1_nA.dat', data0V);

1 Comment

What line is throwing the error?
If you do either whos or which with the variables you are referencing, what are the results?

Sign in to comment.

Answers (1)

Hi,
please use the code button to format your code. I assume the error happens at the line
rowa=scana.data(:,end);
Take a look at the variable scana. The error message suggests it is not a structure...
Titus

2 Comments

Yes the error in this line. But can please explain more you suggestion
Set a breakpoint on that line, and before that line, put these lines
scana
whos scana
don't use semicolons at the end of the line and tell us what it says in the command window.

Sign in to comment.

Tags

Asked:

on 14 Jan 2015

Commented:

on 15 Jan 2015

Community Treasure Hunt

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

Start Hunting!