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);
Unrecognized function or variable 'dt'.
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

Dyuman Joshi
Dyuman Joshi 2023년 11월 24일
Parameter dt is not defined in your code above.
Mohammad Shojaei Arani
Mohammad Shojaei Arani 2023년 11월 24일
Sorry, it is 0.01
What's the problem here?
Though I'm not sure why you have labeled x=1 as 0.
S=load('LandauData.mat');
data=S.data;
L=-2.;R=2.2;
dt = 0.01;
t=dt.*(0:length(data)-1);
[a,b] = bounds(t)
a = 0
b = 999.9900
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'})
Mohammad Shojaei Arani
Mohammad Shojaei Arani 2023년 11월 24일
So, you did not detect any problem.
But, I could fix it after pressing clear. I do not know, perhaps something was interfering with my code lines. But, now it
works.
Mohammad Shojaei Arani
Mohammad Shojaei Arani 2023년 11월 24일
BTW, I cannot accept your answer here (I could not find any botton about it)

댓글을 달려면 로그인하십시오.

 채택된 답변

Chunru
Chunru 2023년 11월 24일

0 개 추천

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'})

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Axis Labels에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by