Hi, I am facing difficulty in plotting these functions.

1 回表示 (過去 30 日間)
saikat ghosh
saikat ghosh 2019 年 7 月 19 日
回答済み: Steven Lord 2019 年 7 月 19 日
k=1;
x=[0:0.5:24];
y1= k*sin(pi*(x-12.9677)/14.8646);
y1(y1 < 0) = 0;
y2= k*sin(pi*(x-16.0495)/12.7009);
y2(y2 < 0) = 0;
y=y1+y2;
plot(x,y1);
hold on
plot(x,y2);
I want to plot y1 and y2 such that after 24 at the x coordinate, y1 and y2 arrive from 0 at x coordinate and the value of y1 at 24 , i.e. y1(24) = y1(0) and the the y curve must follow its original course as it would have followed after 24 but from 0 till the termination on the x-axis.
Here, based on my code (wrong), y1 is not showing up again from 0 till termination point and y2 is showing up but starting at a lower value from 0.
Also please keep in mind that i further wan sum of y1 and y2 in the 0 to 24 range.
0 to 24 is the time of day.
Thanks for reading. we
  2 件のコメント
Enez Furkan Cihan
Enez Furkan Cihan 2019 年 7 月 19 日
編集済み: Enez Furkan Cihan 2019 年 7 月 19 日
I'd try out to expand x axis by 'axis' command to make the figure's axis bigger than your plot's width.
saikat ghosh
saikat ghosh 2019 年 7 月 19 日
Then how I will get the rest of the curve after 24 emerging out from 0?

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

回答 (1 件)

Steven Lord
Steven Lord 2019 年 7 月 19 日
I want to plot y1 and y2 such that after 24 at the x coordinate, y1 and y2 arrive from 0 at x coordinate and the value of y1 at 24 , i.e. y1(24) = y1(0)
In that case you're going to need to change your y1 function. y1(0) will be equal (approximately) at x = 2*14.8646.
>> k = 1;
>> y1 = @(x) k*sin(pi*(x-12.9677)/14.8646);
>> y1([0 24])
ans =
-0.3903 0.7243
>> y1([0 2*14.8646])
ans =
-0.3903 -0.3903
Similarly for y2, with x = 2*12.7009:
>> k = 1;
>> y2 = @(x) k*sin(pi*(x-16.0495)/12.7009);
>> y2([0 24])
ans =
0.7368 0.9227
>> y2([0 2*12.7009])
ans =
0.7368 0.7368

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by