How to display y=0 in figure

1 126 views (last 30 days)
ly
ly on 22 Jan 2016
Answered: EL_DON on 9 Oct 2019
Hi,
I want to display like the figure.
How to display (y=0) like this.
  2 Comments
ly
ly on 22 Jan 2016
I only plot the red curve.
You can see in the second figure, there is a gray curve (y=0) and it is the same with the edge of figure.
How to display that curve???
This is code:
r=[0.1:0.1:10];
epsilo=0.008909;
sigma=3.326;
E=4*0.008909*(sigma^12./r.^12-sigma^6./r.^6)*1000;
plot(r,E,'r');hold on;

Sign in to comment.

Accepted Answer

Ilham Hardy
Ilham Hardy on 22 Jan 2016
r=[0.1:0.1:10];
y = zeros(length(r),1);
epsilo=0.008909;
sigma=3.326;
E=4*0.008909*(sigma^12./r.^12-sigma^6./r.^6)*1000;
plot(r,E,'r');hold on;
plot(r,y,'b');
  1 Comment
ly
ly on 22 Jan 2016
Edited: ly on 22 Jan 2016
No, it isn't a plotted curve. It is a part of figure.
There are many examples about it.

Sign in to comment.

More Answers (4)

Image Analyst
Image Analyst on 22 Jan 2016
Your code doesn't plot anything like those curves, but anyway, add a line specially to draw the x axis:
% Plot X axis along y=0.
line(xlim(), [0,0], 'LineWidth', 2, 'Color', 'k');
grid on;

EL_DON
EL_DON on 9 Oct 2019
refline seems like a pretty simple way to do it, and you can change the slope or intercept if you need different reference lines.
x = [0:0.1:10];
y = sin(x);
plot(x, y);
hline = refline(0, 0);
hline.Color = 'k';
Screenshot_20191009_101539.png

lasindu madushan
lasindu madushan on 11 Aug 2019
I want to create ball shooting game for these requirments
Can you help?
In this game, an animation should be created to display the flying trajectories of the ball shot from a fixed initial height and fixed initial velocity at release. The game player will attempt to adjust the release angle (shooting angle) of the ball to hit a board placed at the ground. Once the ball hits the board, the player will score one point. Then, the board will be randomly re-located to another position for the player to attempt another round. The specific design requirements are given below:
• Initial height of ball at release is fixed at 1.5 m. • Initial velocity of ball at release is fixed at 4 m/s. • Board length is of 0.5 m and located at height 0 horizontally. • Diameter of ball is approximately one-third of the board length. • The ball should be at rest on the board for at least 0.5 second once hit. • The board should be randomly re-located within a range reachable by the ball for each new round. • Scores should be displayed. • The player could adjust the shooting angle in command window and command the action of shooting. • The program should have a command for player to exit the program. • The program should handle exceptions such as when player enters an invalid shooting angle, etc. • The program should not crash MATLAB during running (i.e., good reliability). • You may add additional functions to your program to make it funny.
The following tasks are for students aiming for High Distinction (HD) grade of their portfolios. To get HD marks, you must ensure all the other tasks have been completed and been signed off by the tutor when submitting your final portfolio.
For High Distinction Tasks, you also need to demonstrate the programs to your tutor and answer the questions if any.
29 | P a g e
Show the screenshot of your game interface and the animation snapshots. You should add comments in your program to describe the codes allowing others to understand your code easily. You need to demonstrate the program to the tutor for sign-off.
  1 Comment
Image Analyst
Image Analyst on 12 Aug 2019
See attached demo for a projectile. Adapt as needed. It doesn't have a GUI with a board on it - it just makes some plots - so you'd have to add that.

Sign in to comment.


Steven Lord
Steven Lord on 12 Aug 2019
As of release R2015b you can set the XAxisLocation property of the axes to 'origin'.

Categories

Find more on Strategy & Logic 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!