A problem with xtick
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Mohammad Shojaei Arani
el 24 de Nov. de 2023
Comentada: Mohammad Shojaei Arani
el 24 de Nov. de 2023
Hello,
I do not know but I could not figure out how to fix a problem with xticks (I hate it). I also attach the data I am using. Bellow, are a few code lines
S=load('LandauData.mat');
data=S.data;
L=-2.;R=2.2;
t=dt.*(0:length(data)-1);
plot(t,data,'-k');
hold on;
plot(t,0.*t+L,'--r');
plot(t,0.*t+R,'--r');
ylim([-10 11.7]);
xlabel('time');
ylabel('State, x');
title('Landau model');
yticks([-10 -6 -2 2 6 10]);
yticklabels([-10 -6 -2 2 6 10]);
xticks([1 200 400 600 800 1000]);
xticklabels({'0','200','400','600','800','1000'})
I do not know why I get the folowing error message
Index exceeds the number of array elements. Index must not exceed 6.
Thanks for your kind help in advance!
Babak
5 comentarios
Respuesta aceptada
Chunru
el 24 de Nov. de 2023
It works here without problem.
S=load(websave("LandauData.mat", "https://www.mathworks.com/matlabcentral/answers/uploaded_files/1551452/LandauData.mat"));
data=S.data;
L=-2.;R=2.2;
dt = 0.01;
t=dt.*(0:length(data)-1);
plot(t,data,'-k');
hold on;
plot(t,0.*t+L,'--r');
plot(t,0.*t+R,'--r');
ylim([-10 11.7]);
xlabel('time');
ylabel('State, x');
title('Landau model');
yticks([-10 -6 -2 2 6 10]);
yticklabels([-10 -6 -2 2 6 10]);
xticks([1 200 400 600 800 1000]);
xticklabels({'0','200','400','600','800','1000'})
Más respuestas (0)
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!