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 CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by