{"id":20,"date":"2023-05-24T16:56:02","date_gmt":"2023-05-24T15:56:02","guid":{"rendered":"http:\/\/www.reading-uk.net\/?p=20"},"modified":"2023-05-25T15:39:05","modified_gmt":"2023-05-25T14:39:05","slug":"how-to-plot-a-diagrams","status":"publish","type":"post","link":"https:\/\/www.reading-uk.net\/en\/how-to-plot-a-diagrams\/","title":{"rendered":"How to plot a diagrams"},"content":{"rendered":"\n<p>Let&#8217;s use the example from the post about BASIC programing &#8211; Example BASIC program. To plot the graph of a quadratic equation on the ZX Spectrum, you can use the built-in graphics capabilities of the computer. Here&#8217;s an example ZX Spectrum Basic program that plots the graph of a quadratic equation:<\/p>\n\n\n\n<p class=\"has-text-align-left\">10 PRINT &#8220;Quadratic Equation Graph&#8221;<br>20 PRINT &#8220;Enter the coefficients:&#8221;<br>30 INPUT &#8220;a: &#8220;, a<br>40 INPUT &#8220;b: &#8220;, b<br>50 INPUT &#8220;c: &#8220;, c<br>60 LET x = -10<br>70 LET y = a<em>*<\/em>x*x + b*<em>x + c <\/em><br><em>80 FOR i = 1 TO 20 <\/em><br><em>90 LET x = x + 1 <\/em><br><em>100 LET y = a<\/em>*x*<em>x + b<\/em>*x + c<br>110 PLOT x+128, 96-y<br>120 NEXT i<br>130 PRINT &#8220;End of program&#8221;<\/p>\n\n\n\n<p>This program prompts the user to enter the coefficients (a, b, and c) of a quadratic equation. It then uses a loop to calculate the y-coordinate for a range of x-values (-10 to 10 in this example) using the quadratic equation formula.<\/p>\n\n\n\n<p>The PLOT statement is used to plot the calculated points on the screen. The x-coordinate is adjusted by adding 128 to center the graph horizontally, and the y-coordinate is subtracted from 96 to invert the graph vertically since the screen coordinates on the ZX Spectrum start from the top-left corner.<\/p>\n\n\n\n<p>The loop iterates through the range of x-values, calculates the corresponding y-values, and plots the points on the screen. The result is a graph that represents the quadratic equation.<\/p>\n\n\n\n<p>Finally, the program prints &#8220;End of program&#8221; to indicate the completion of the execution.<\/p>\n\n\n\n<p>You can type and run this program on a ZX Spectrum computer or in an emulator to plot the graph of a quadratic equation. The resulting graph will be displayed on the screen.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Let&#8217;s use the example from the post about BASIC programing &#8211; Example BASIC program. To&#8230;<\/p>\n","protected":false},"author":1,"featured_media":88,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-20","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming"],"_links":{"self":[{"href":"https:\/\/www.reading-uk.net\/en\/wp-json\/wp\/v2\/posts\/20","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.reading-uk.net\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.reading-uk.net\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.reading-uk.net\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.reading-uk.net\/en\/wp-json\/wp\/v2\/comments?post=20"}],"version-history":[{"count":3,"href":"https:\/\/www.reading-uk.net\/en\/wp-json\/wp\/v2\/posts\/20\/revisions"}],"predecessor-version":[{"id":23,"href":"https:\/\/www.reading-uk.net\/en\/wp-json\/wp\/v2\/posts\/20\/revisions\/23"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.reading-uk.net\/en\/wp-json\/wp\/v2\/media\/88"}],"wp:attachment":[{"href":"https:\/\/www.reading-uk.net\/en\/wp-json\/wp\/v2\/media?parent=20"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.reading-uk.net\/en\/wp-json\/wp\/v2\/categories?post=20"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.reading-uk.net\/en\/wp-json\/wp\/v2\/tags?post=20"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}