LugoBlogger - MATLAB Cody - MATLAB Central

LugoBlogger

65354
Rank
2
Badges
40
Score
1 – 5 of 5

LugoBlogger submitted a Comment to Problem 46833. Roots, Bloody Roots: part 1/2

Hi, Rafael. I tried your problem and my solution only passed test suite #3. I used complex number to represent the coordinates. From that, I computed abs() and angle(). I assumed that row m is corresponding to positive y-axis, and column n is positive x-axis. For m or n is odd, the center is exactly the midpoint of the array 1:m or 1:n, but for m or n is even, I put two elements for each for the origin. Therefore, we have 2x2 array for the origin when m and n is even or 2x1 if m is even and n is odd, or 1x2 m is odd or n is even. Before that I also tried with simple origin by taking the floor(([m, n]+1)/2). Unfortunately, those two approaches didn't give the same results as yours. I plot the `cp` array (m x n x 3) using `image` and the plot is same as your image. I also flip the each HSV array, because Matlab use the convention for angle start from -pi to pi (in this problem it points to negative y axis). Thank you.

on 9 May 2021

LugoBlogger received Solver badge for Solution 5727540

on 8 May 2021

1 – 5 of 5
Go to top of page