Index exceeds matrix dimensions ERROR
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Alex Mcaulley
el 24 de Jul. de 2019
Here is the problem:
XYData(:,cb)
But we don't know the values of those variables. What is the result of
whos XYData
cb
Respuestas (1)
Jan
el 24 de Jul. de 2019
Editada: Jan
el 24 de Jul. de 2019
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;
?
0 comentarios
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!