Hi, I am facing difficulty in plotting these functions.

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Annotations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by