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
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.
답변 (1개)
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
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!