Index exceeds matrix dimensions ERROR
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
Torsten
el 24 de Jul. de 2019
I don't see a line where you assign values to "cbi" or "cbf".
Alex Sune
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
Mariaelena
el 24 de Jul. de 2019
Respuestas (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;
?
Categorías
Más información sobre Matrix Indexing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!