 # How to draw the Japan flag using MATLAB

MATLAB, also called Matrix Laboratory, is a computing environment and platform for programming languages. It was designed and developed by MathWorks. MATLAB — it is a framework that allows us to perform matrix manipulations, implement algorithms, display functions and data, create user interfaces and interact with programs written in different programming languages ​​such as C, C ++, Python, Java, etc.

How to draw a color image in MATLAB?
A color image can be represented as a 3-order matrix. The first order is for rows, the second order is for columns, and the third order is for specifying the color of the corresponding pixel. We are using RGB color format here, so the third order will take 3 values ​​Red, Green and Blue, respectively. The row and column values ​​depend on the size of the image.

Approach to draw the flag of Japan:

• Create an order 3 zero matrix measuring (300 , 500, 3), where 300 is the number of pixels for rows, 600 is the number of rows, and 3 is RGB color coding.
• First color the entire matrix white. RGB for red (255, 255, 255).
` I (:,:,:) = 255; `
• Loop over rows and columns and implement the equation of the circle so that we got the circle in the center of the flag and colored it in crimson glory using RGB format.
Circle equation:
` ((xh) ^ 2 - (yk) ^ 2) = r ^ 2 `

where (h, k) & # 8212 ; centers, (x, y) — the x-axis and y-axis coordinates and the radius of the circle.
RGB format for crimson glory color (188, 0, 45).

Below is the code:

 `% create a 2-D matrix and paint it white ` ` I = uint8 (zeros (300, 500, 3)) + 255; `   `% center 1 through which the circle will pass ` ` circle_center1 = 150; `   `% of the center point 2 that the circle will pass through ` ` circle_center2 = 250; `   ` radius = 6.32; ` `% circle radius ` ` x = i; ` `% X-axis ` ` y = j; ` `% y-coordinate `   `% loops for strings, ie for the X axis ` ` ` ` for ` ` i = 101: 200 `   `% column loops, i.e. for Y-axis ` ` for ` ` j = 101: 300 `   `% apply the circle equation to make a circle in the center. ` ` if ` ` round (sqrt ((i-circle_center1) ^ 2 + (j-circle_center2) ^ 2)) & lt; radius ^ 2 `   `% fill the circle with crimson glory ` `% color using RGB color representation. ` ` I (i, j, 1) = 188; ` ` I (i, j, 2) = 0; ` ` I (i, j, 3) = 45; `   ` end `  ` `  ` ` ` end ` `% end of column loop. ` ` end ` `% end of line loop. `   `% show the rendered image. ` ` figure, imshow (I); `

Output: 