How to change the y-axis values to start at 0 and not become negative?
조회 수: 40 (최근 30일)
이전 댓글 표시
How can i make it so that my plot starts at 0 and doesn't go below 0 into the negative numbers, also I'd like to use a range from 0 to 1.7 on my y-axis but am unable to. Thank you!
clc;
close all;
clear all;
% Importing video from files
vid = VideoReader('portfolio3/Tennis1.mp4');
% Converting the video into frames
frames = read(vid);
% Finding the size and length of the video
si = size(frames)
% % Creating a vector to store positions of the vector
posVec = [];
%% Cropping and greying the video for facile processing
% for all frames
for i = 1 : si(4)
% Cropping frame by frame
CroppedFrame = imcrop(frames(:,:,:,i),[120 90 450 1000]);
% Coverting to grey
CroppedFrame = rgb2gray(CroppedFrame);
% Binarising
CroppedFrame = im2bw(CroppedFrame,0.7);
% Removing flexes
CroppedFrame = imopen(CroppedFrame,strel('disk',3));
imshow(CroppedFrame);
% Tracking the ball in the video
[pos,rad] = imfindcircles(CroppedFrame,[13 100]);
viscircles(pos,rad);
drawnow
% Adding the current position to the position vector
posVec = [posVec; pos];
end
scatter(65-posVec(:,1),365-posVec(:,2));
pbaspect([1000 1000 1000])
hold on;
title('Bouncing Ball Trajectory')
xlabel('Horizontal Displacement')
ylabel('Vertical Displacement')
This is what I am getting so far
댓글 수: 0
채택된 답변
Jan
2021년 4월 29일
It is not clear, what you are asking for.
You can limit the Y axis by:
ylim([0, 1.7])
This would crop almost all points from the diagram.
Maybe you want to scale the data instead. Where do the constants in this expression come from:
scatter(65-posVec(:,1),365-posVec(:,2));
% ^^ ^^^ ?
What about:
posVec = -posVec;
posVec = posVec - min(posVec); % Starting at 0
posVec = 1.7 * posVec / max(posVec); % maximum value scaled to 1.7
댓글 수: 1
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!