Javascript數學函數sin與cos對比EXCEL函數

Javascript在網頁就可以執行不需要開啟Spyder

以上原始程式碼

<style>BUTTON{BORDER:GREEN 10PX SOLID;BORDER-RADIUS:30PX;FONT-SIZE:30PX;COLOR:BLUE;}</style>
<h1>Javascript在網頁就可以執行不需要開啟Spyder</h1>
<button onclick="LHsin()">sin執行</button>
<button onclick="LHcos()">cos執行</button>
<button onclick="xLine()">橫軸</button>
<canvas height="400" id="my" style="background: black;" width="1200"></canvas>
<script>
var c = document.getElementById("my");
var cty = c.getContext("2d");
var g = 0.01;//增加一個廣域變數,用在下面的Math.sin(g*x);
var h = 195;
function LHsin()
{
var x = 0;
var y = 200;
cty.beginPath(); 
cty.lineWidth = 5; 
cty.moveTo(x,y);
while (x < 1000){
  x = x + 1;
  y = 200 - h * Math.sin(g*x);//數學Math正弦sin
  cty.lineTo(x, y);
  cty.strokeStyle = "yellow";
  cty.stroke();
   };
}
function LHcos()
{
var x = 0;
var y = 200-h;//上面的sin是y =200這裡要改掉
cty.beginPath(); 
cty.lineWidth = 5; 
cty.moveTo(x,y);
while (x < 1000){
  x = x + 1;
  y = 200 - h * Math.cos(g*x);
  cty.lineTo(x, y);
  cty.strokeStyle = "red";
  cty.stroke();
   };
}
function xLine(){
cty.beginPath(); 
cty.lineWidth = 3; 
cty.moveTo(0,200);    cty.lineTo(1050,200);cty.lineTo(1050,210);cty.lineTo(1100,200);cty.lineTo(1050,190);cty.lineTo(1050,200);
    cty.strokeStyle = "white";
    cty.stroke();
    cty.font= "60px Georgia";
    cty.fillStyle = "white";
    for ( i = 0; i < 11; i++) 
      cty.fillText(i, i/g, 240);
}
</script>
<div class="separator" style="clear: both;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiw1ZEA-R9ZBunWYuSbvWJCUlqcltUgoO9nDxbxt_Esxs052jZcmeqOhD3oUm9Wq5FHeSztKq1QVSr2nWYJh5cR1s0iIAA2mj1B0QjC1kiVWF6oZ_UnuezJX7JPTFjRH7kOrOIX_Sg5UNZwqCklicI4yRRIQ1sfOp9kScIq2o63ZaCnq3C9Gl_c5At-DvA/s1600/%E5%9C%96%E7%89%871.jpg" style="display: block; padding: 1em 0; text-align: center; "><img alt="" border="0" data-original-height="2196" data-original-width="3359" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiw1ZEA-R9ZBunWYuSbvWJCUlqcltUgoO9nDxbxt_Esxs052jZcmeqOhD3oUm9Wq5FHeSztKq1QVSr2nWYJh5cR1s0iIAA2mj1B0QjC1kiVWF6oZ_UnuezJX7JPTFjRH7kOrOIX_Sg5UNZwqCklicI4yRRIQ1sfOp9kScIq2o63ZaCnq3C9Gl_c5At-DvA/s1600/%E5%9C%96%E7%89%871.jpg"/></a></div>
<iframe width="560" height="315" src="https://www.youtube.com/embed/QiDaMpjVgB0?si=gp4zkDJI-5F3Shyk" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>

留言

  1. https://lu-chieh-chi.blogspot.com/2025/05/javascriptsincosexcel.html

    回覆刪除
  2. https://lintingyang11317134.blogspot.com/2025/05/buttonbordergreen-5px-solidborder_27.html

    回覆刪除
  3. https://ben0409.blogspot.com/2025/05/javascriptsincosexcel.html

    回覆刪除
  4. https://yangsinmei.blogspot.com/2025/05/javascriptsincosexcel.html

    回覆刪除
  5. https://allyking097.blogspot.com/2025/05/buttonbordergreen-5px-solidborder.html

    回覆刪除
  6. https://jiang-jia-ehen.blogspot.com/2025/05/javascriptfontfillstylefilltext.html

    回覆刪除
  7. https://zzy-hn.blogspot.com/2025/05/javascriptspyder.html

    回覆刪除
  8. https://jjjjiaying.blogspot.com/2025/05/buttonbordergreen-5px-solidborder.html

    回覆刪除
  9. https://lupeiying.blogspot.com/2025/05/javascriptfontfillstylefilltext.html

    回覆刪除
  10. https://djhdvdhd.blogspot.com/2025/05/blog-post_27.html

    回覆刪除
  11. https://hsulining9999.blogspot.com/2025/05/javascriptfontfillstylefilltext.html

    回覆刪除
  12. https://xie-ni.blogspot.com/2025/05/javascriptsincosexcel.html

    回覆刪除
  13. https://yangbokai.blogspot.com/2025/05/javascriptsincosexcel.html

    回覆刪除
  14. https://xin00.blogspot.com/2025/05/javascriptfontfillstylefilltext.html

    回覆刪除
  15. https://shanny11336108.blogspot.com/2025/05/javascriptfontfillstylefilltext.html

    回覆刪除
  16. https://wihfaw.blogspot.com/2025/05/buttonbordergreen-5px-solidborder_27.html

    回覆刪除
  17. https://zhuo-you-wen.blogspot.com/2025/05/javascriptsincosexcel.html

    回覆刪除
  18. https://jiang233.blogspot.com/2025/05/javascriptsincosexcel.html

    回覆刪除
  19. https://laichia-jung.blogspot.com/2025/05/javascriptsimcosexcel.html

    回覆刪除
  20. https://guovupvmp.blogspot.com/2025/05/buttonbordergreen-5px-solidborder.html

    回覆刪除
  21. https://yichen0617.blogspot.com/2025/05/javascriptsincoscanvasfont_27.html

    回覆刪除
  22. https://anson0501.blogspot.com/2025/05/buttonbordergreen-5px-solidborder.html

    回覆刪除
  23. https://chenwewen.blogspot.com/2025/05/javascriptfontfillstylefilltext.html

    回覆刪除
  24. https://huangyunchieh.blogspot.com/2025/05/javascriptsincosexcel_27.html

    回覆刪除
  25. https://ericfggf554466.blogspot.com/2025/05/javascriptfontfillstylefilltext.html

    回覆刪除
  26. https://xiyuying.blogspot.com/2025/05/javascriptfontfillstylefilltext.html

    回覆刪除
  27. https://kuchingyu.blogspot.com/2025/05/javascriptfontfillstylefilltext.html

    回覆刪除
  28. https://yezonghan.blogspot.com/2025/05/buttonbordergreen-5px-solidborder.html

    回覆刪除
  29. https://spy0928.blogspot.com/2025/05/javascriptsincosexcel.html

    回覆刪除

張貼留言

這個網誌中的熱門文章

柯聞折Javascript物件導向方法是物件的函數

甲劉任昌python串列List(陣列Array),元組Tuple,集合Set,字典Dict

周偉玲Python執行IRR