Attempt to reference field of non-structure array.
4 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Star Strider
2015 年 1 月 14 日
What line is throwing the error?
If you do either whos or which with the variables you are referencing, what are the results?
回答 (1 件)
Titus Edelhofer
2015 年 1 月 14 日
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 件のコメント
Image Analyst
2015 年 1 月 15 日
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.
参考
カテゴリ
Help Center および File Exchange で Blue についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!