[Scilab-users] plotting a function that changes with x

Lloyd Judd ltjudd at bigpond.com
Sun Feb 9 08:56:54 CET 2020


Hello, 
I am trying make a plot, the function of which changes depending on the 
value of x,. What I am really trying to do is to simulate solar panel 
out put where it roughly follows a sine  function during daylight but is 
basically zero from sunset to sunrise, and then later overlay that with 
the demand curve. But I am still experimenting with the code at this 
stage.
 I tried all different ways;  using the "function" command and the "plot 
2d" command . It only ever seems  to plot the last argument in the "if 
then else" statement.
For example with this code;
clf
   x=(0:1:72)
  if x<18
      then y = sin(x*%pi/24)
  else
      y= 0.1*x
   end
  plot2d(x,y,2)it only plots  the y=0.1x partConversely if I put the 
sine function under the "else" statement, it only plots the  sin 
function.clfx=(0:1:72)
if x<18 then
     y=0.01*x
else
     y=sin(x*%pi/24)
end
  plot2d(x,y,2)What is the best way to plot a function that changes 
depending on the range of x?Thanks and regardsLloyd Judd

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20200209/76cebf48/attachment.htm>


More information about the users mailing list