Index exceeds matrix dimensions ERROR
显示 更早的评论
Hi, can somebody figure out why I get this error message? Thank you very much!
Index exceeds matrix dimensions.
Error in gidilm1>localPlot (line 244)
line_h=line(t,XYData(:,cb),'UserData',cb,'ButtonDownFcn','gidilm1
line','Tag','lin','Color',col)%,'Marker','+');
Error in gidilm1 (line 95)
line_h(i)=localPlot(i,ax,colory(i-cbi+1,:));
Error while evaluating UIControl Callback
function line_h=localPlot(cb,ax,col)
global XYData t
cb;
ax;
col;
line_h=line(t,XYData(:,cb),'UserData',cb,'ButtonDownFcn','gidilm1 line','Tag','lin','Color',col)%,'Marker','+');
axis(ax)
%axis([0 19.8 0.05 0.5])
axe=gca
%set(axe,'Xtick',[0:2:40])
xlabel('TEMPS (h)')
ylabel('DO')
% figure
for i=cbi:cbf
line_h(i)=localPlot(i,ax,colory(i-cbi+1,:));
end
ts=ax(1):50:ax(2)+60;
dos=doseuil.*(ones(1,length(ts)));
line(ts,dos,'Color','b')
3 个评论
Torsten
2019-7-24
I don't see a line where you assign values to "cbi" or "cbf".
Alex Sune
2019-7-24
Here is the problem:
XYData(:,cb)
But we don't know the values of those variables. What is the result of
whos XYData
cb
Mariaelena
2019-7-24
回答(1 个)
Using global variables is a bad programming style. It impedes the debugging massively. It is hard to find out, which code has set the values of t, XData and cb the last time. Obviously these values contain a problem. Prefer to use input and output arguments instead. For sharing variables between callbacks: https://www.mathworks.com/matlabcentral/answers/?term=share+variables+between+callbacks
What is the meaning of these lines:
cb;
ax;
col;
?
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!