Hi All,
I have x and y column vector of data. x is universal time starts from 0-24. I want to plot local time of figure 0-24 LT. The LT=UT+7
I wrote a code like this but it does not work.
x=[0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24];
y=[0.2;0.3;0.4;0.2;0.7;0.4;0.6;0.3;0.2;0.4;0.2;0.4;0.6;0.2;0.4;0.5;0.7;0.2;0.3;0.2;0.6;0.4;0.2;0.3;0.2];
if (0<=x<=17)
x=x+7;
else
x=x-17;
end
Would you please help me to correct it?

2 件のコメント

VBBV
VBBV 2022 年 12 月 20 日
What is y vector ? Are they some data at those times ?
Ara
Ara 2022 年 12 月 20 日
Y vector is not the same as X vector. Yes they are some data at those times.

サインインしてコメントする。

 採用された回答

VBBV
VBBV 2022 年 12 月 20 日
編集済み: VBBV 2022 年 12 月 20 日

0 投票

x=[0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24];
y=[0.2;0.3;0.4;0.2;0.7;0.4;0.6;0.3;0.2;0.4;0.2;0.4;0.6;0.2;0.4;0.5;0.7;0.2;0.3;0.2;0.6;0.4;0.2;0.3;0.2];
for k = 1:length(x)
if x(k)>0 & x(k)<=17
x(k)=x(k)+7;
else
x(k)=x(k)-17;
end
end
plot(x)

その他の回答 (1 件)

Alan Stevens
Alan Stevens 2022 年 12 月 20 日

0 投票

Use the mod function
help mod

カテゴリ

ヘルプ センター および File ExchangeGet Started with MATLAB についてさらに検索

質問済み:

Ara
2022 年 12 月 20 日

コメント済み:

Ara
2022 年 12 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by