Graph from 0º to 360º
14 views (last 30 days)
Show older comments
Commented: Image Analyst on 1 Apr 2022
Greetings community. I need to graph this function but my problem is that I use the function ''regionprops, Orientation'' which works between -90º and 90º. I need this graph to be between 0º and 360º. I get the points from a sequence of images in which I analyze the ''Centroid'' of a figure. I attach parts of the code
%This is the line with which I plot the orientation (which corresponds to the matrix Mtaco(:,5))
plot(Mtaco(:,1), Mtaco(:,5),'o'), grid on, title('Orientacion');
I attach an image of the graphed function, I need that on the ordinate axis they are from 0º to 360º
Thank you very much for your attention and for your help.
Mahmoud Ashraf on 1 Apr 2022
l think you need to change the limit of axes
you can do it by
axis([0 800 -360 360])
Voss on 1 Apr 2022
plot(Mtaco(:,1), mod(Mtaco(:,5),360),'o'), grid on, title('Orientacion');
So if a blob was aligned along the 45 degree angle, would you want the orientation to be 45 or 225? If it was at 90 degrees, would you want it to be at 90 degrees or 270 degrees? Explain how you would get angles more than 180 degrees and why they could not be the same angle as that angle minus 180 degrees.
How did you fill up Mtaco? I guess you put the orientation angles into column 5.
Why don't you just add 180 to any values less than 0?
Mtaco(:, 5) = Mtaco(:, 5) + 180;
Now your range is 0 to 180. Going more than 180 doesn't make sense.
To add them to ONLY values like than 0, you need to get a mask of just those values less than 0.
rowsWithNegValues = Mtaco(:, 5); % Rows with negative values in column 5.
Mtaco(rowsWithNegValues, 5) = Mtaco(rowsWithNegValues, 5) + 180; % Reassign only negative numbers.
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!