Getting shifted frequency curves instead of normal ones

조회 수: 2 (최근 30일)
Ramo Rafsel
Ramo Rafsel 2020년 9월 22일
댓글: Ameer Hamza 2020년 9월 24일
Why do I get somehow displaced curves ( see first picture) that should normally be an unshifted curve?(see the second picture)
The frequency is calculated through given frequency values and a time column
The code looks like the following
nexttile
Fd1 = double(split(string(fdim1(1:end-1)) , ","));
Fd1 = Fd1(:,1);
plot(timefdim1(1:end-1),Fd1);
xticks([timefdim1(1) timefdim1(end-1)]);
yticks([Fd1(1) Fd1(end-1)]);
title('dimfrequency 1')
xlabel('Uhrzeit in [HH:MM:SS]')
ylabel('Frequenzintervall 150kHz - 80 MHz')
nexttile
Fd2 = double(split(string(fdim2(2:end-1)) , ","));
Fd2 = Fd2(:,1);
plot(timefdim2(2:end-1),Fd2);
xticks([timefdim2(2) timefdim2(end-1)]);
yticks([Fd2(2) Fd2(end-1)]);
title('dimfrequency 2')
xlabel('Uhrzeit in [HH:MM:SS]')
ylabel('Frequenzintervall 80 MHz - 1 GHz')
nexttile
Fd3 = double(split(string(fdim3(3:end-1)) , ","));
Fd3 = Fd3(:,1);
plot(timefdim3(3:end-1),Fd3);
xticks([timefdim3(1) timefdim3(end-1)]);
yticks([Fd3(1) Fd3(end-1)])
title('dimfrequency 3')
xlabel('Uhrzeit in [HH:MM:SS]')
ylabel('Frequenzintervall 1 GHz - 2,7 GHz')
nexttile
F1 = double(split(string(fbll1(1:end-1)) , ","));
F1 = F1(:,1);
plot(timefbll1(1:end-1),F1);
xticks([timefbll1(1) timefbll1(end-1)]);
yticks([F1(1) F1(end-1)]);
title('bllfrequency 1')
xlabel('Uhrzeit in [HH:MM:SS]')
ylabel('Frequenzintervall 150kHz - 80 MHz')
nexttile
F2 = double(split(string(fbll2(2:end-1)) , ","));
F2 = F2(:,1);
plot(timefbll2(2:end-1),F2);
xticks([timefbll2(2) timefbll2(end-1)]);
yticks([F2(2) F2(end-1)]);
title('bllfrequency 2')
xlabel('Uhrzeit in [HH:MM:SS]')
ylabel('Frequenzintervall 80 MHz - 1 GHz')
nexttile
F3 = double(split(string(fbll3(3:end-1)) , ","));
F3 = F3(:,1);
plot(timefbll3(3:end-1),F3);
xticks([timefbll3(1) timefbll3(end-1)]);
yticks([F3(1) F3(end-1)])
title('bllfrequency 3')
xlabel('Uhrzeit in [HH:MM:SS]')
ylabel('Frequenzintervall 1 GHz - 2,7 GHz')
Thanks a lot in advance for the help.
  댓글 수: 4
Ameer Hamza
Ameer Hamza 2020년 9월 22일
Can you share the code you are using to create the plots?
Ramo Rafsel
Ramo Rafsel 2020년 9월 22일
This is the written code for the plotting:
nexttile
Fd1 = double(split(string(fdim1(1:end-1)) , ","));
Fd1 = Fd1(:,1);
plot(timefdim1(1:end-1),Fd1);
xticks([timefdim1(1) timefdim1(end-1)]);
yticks([Fd1(1) Fd1(end-1)]);
title('dimfrequency 1')
xlabel('Uhrzeit in [HH:MM:SS]')
ylabel('Frequenzintervall 150kHz - 80 MHz')
nexttile
Fd2 = double(split(string(fdim2(2:end-1)) , ","));
Fd2 = Fd2(:,1);
plot(timefdim2(2:end-1),Fd2);
xticks([timefdim2(2) timefdim2(end-1)]);
yticks([Fd2(2) Fd2(end-1)]);
title('dimfrequency 2')
xlabel('Uhrzeit in [HH:MM:SS]')
ylabel('Frequenzintervall 80 MHz - 1 GHz')
nexttile
Fd3 = double(split(string(fdim3(3:end-1)) , ","));
Fd3 = Fd3(:,1);
plot(timefdim3(3:end-1),Fd3);
xticks([timefdim3(1) timefdim3(end-1)]);
yticks([Fd3(1) Fd3(end-1)])
title('dimfrequency 3')
xlabel('Uhrzeit in [HH:MM:SS]')
ylabel('Frequenzintervall 1 GHz - 2,7 GHz')
nexttile
F1 = double(split(string(fbll1(1:end-1)) , ","));
F1 = F1(:,1);
plot(timefbll1(1:end-1),F1);
xticks([timefbll1(1) timefbll1(end-1)]);
yticks([F1(1) F1(end-1)]);
title('bllfrequency 1')
xlabel('Uhrzeit in [HH:MM:SS]')
ylabel('Frequenzintervall 150kHz - 80 MHz')
nexttile
F2 = double(split(string(fbll2(2:end-1)) , ","));
F2 = F2(:,1);
plot(timefbll2(2:end-1),F2);
xticks([timefbll2(2) timefbll2(end-1)]);
yticks([F2(2) F2(end-1)]);
title('bllfrequency 2')
xlabel('Uhrzeit in [HH:MM:SS]')
ylabel('Frequenzintervall 80 MHz - 1 GHz')
nexttile
F3 = double(split(string(fbll3(3:end-1)) , ","));
F3 = F3(:,1);
plot(timefbll3(3:end-1),F3);
xticks([timefbll3(1) timefbll3(end-1)]);
yticks([F3(1) F3(end-1)])
title('bllfrequency 3')
xlabel('Uhrzeit in [HH:MM:SS]')
ylabel('Frequenzintervall 1 GHz - 2,7 GHz')

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

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 9월 22일
편집: Ameer Hamza 2020년 9월 22일
The time vectors were stored in categorical datatype (bad choice). Therefore, you were getting that unexpected plots. Try the following code. I have only added lines before the plot() statement.
nexttile
Fd1 = double(split(string(fdim1(1:end-1)) , ","));
Fd1 = Fd1(:,1);
timefdim1 = duration(string(timefdim1));
plot(timefdim1(1:end-1),Fd1);
xticks([timefdim1(1) timefdim1(end-1)]);
yticks([Fd1(1) Fd1(end-1)]);
title('dimfrequency 1')
xlabel('Uhrzeit in [HH:MM:SS]')
ylabel('Frequenzintervall 150kHz - 80 MHz')
nexttile
Fd2 = double(split(string(fdim2(2:end-1)) , ","));
Fd2 = Fd2(:,1);
timefdim2 = duration(string(timefdim2));
plot(timefdim2(2:end-1),Fd2);
xticks([timefdim2(2) timefdim2(end-1)]);
yticks([Fd2(2) Fd2(end-1)]);
title('dimfrequency 2')
xlabel('Uhrzeit in [HH:MM:SS]')
ylabel('Frequenzintervall 80 MHz - 1 GHz')
nexttile
Fd3 = double(split(string(fdim3(3:end-1)) , ","));
Fd3 = Fd3(:,1);
timefdim3 = duration(string(timefdim3));
plot(timefdim3(3:end-1),Fd3);
xticks([timefdim3(1) timefdim3(end-1)]);
yticks([Fd3(1) Fd3(end-1)])
title('dimfrequency 3')
xlabel('Uhrzeit in [HH:MM:SS]')
ylabel('Frequenzintervall 1 GHz - 2,7 GHz')
nexttile
F1 = double(split(string(fbll1(1:end-1)) , ","));
F1 = F1(:,1);
timefbll1 = duration(string(timefbll1));
plot(timefbll1(1:end-1),F1);
xticks([timefbll1(1) timefbll1(end-1)]);
yticks([F1(1) F1(end-1)]);
title('bllfrequency 1')
xlabel('Uhrzeit in [HH:MM:SS]')
ylabel('Frequenzintervall 150kHz - 80 MHz')
nexttile
F2 = double(split(string(fbll2(2:end-1)) , ","));
F2 = F2(:,1);
timefbll2 = duration(string(timefbll2));
plot(timefbll2(2:end-1),F2);
xticks([timefbll2(2) timefbll2(end-1)]);
yticks([F2(2) F2(end-1)]);
title('bllfrequency 2')
xlabel('Uhrzeit in [HH:MM:SS]')
ylabel('Frequenzintervall 80 MHz - 1 GHz')
nexttile
F3 = double(split(string(fbll3(3:end-1)) , ","));
F3 = F3(:,1);
timefbll3 = duration(string(timefbll3));
plot(timefbll3(3:end-1),F3);
xticks([timefbll3(1) timefbll3(end-1)]);
yticks([F3(1) F3(end-1)])
title('bllfrequency 3')
xlabel('Uhrzeit in [HH:MM:SS]')
ylabel('Frequenzintervall 1 GHz - 2,7 GHz')
  댓글 수: 2
Ramo Rafsel
Ramo Rafsel 2020년 9월 24일
편집: Ramo Rafsel 2020년 9월 24일
Thanks a lot Ameer, you solved a problem that I have been dealing with weeks long!
I just thought maybe I can ask this too since it is the next step and I am not sure whether it is even possible or not.
Is it possible to plot both figures in one, even though both vectors (or the time length) of the two figures are not the same? (see the picture)
The first figure contains the blue average line and the frequency, the second figure contains a variable in Volt.
Ameer Hamza
Ameer Hamza 2020년 9월 24일
Yes, it is possible. You can use hold() command and then call several plot commands. All of them will be drawn on one axes
hold on
plot(...)
plot(...)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by