Hi, I am facing difficulty in plotting these functions.

1 vue (au cours des 30 derniers jours)
saikat ghosh
saikat ghosh le 19 Juil 2019
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 commentaires
Enez Furkan Cihan
Enez Furkan Cihan le 19 Juil 2019
Modifié(e) : Enez Furkan Cihan le 19 Juil 2019
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 le 19 Juil 2019
Then how I will get the rest of the curve after 24 emerging out from 0?

Connectez-vous pour commenter.

Réponses (1)

Steven Lord
Steven Lord le 19 Juil 2019
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

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by