How to display y=0 in figure

327 次查看(过去 30 天)
Hi,
I want to display like the figure.
How to display (y=0) like this.
  2 个评论
Thorsten
Thorsten 2016-1-22
编辑:Thorsten 2016-1-22
What exactly is your problem? What have you done so far? Please provide the code you have tried to generate the figure.
ly
ly 2016-1-22
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;

请先登录,再进行评论。

采纳的回答

Ilham Hardy
Ilham Hardy 2016-1-22
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 个评论
ly
ly 2016-1-22
编辑:ly 2016-1-22
No, it isn't a plotted curve. It is a part of figure.
There are many examples about it.

请先登录,再进行评论。

更多回答(4 个)

Image Analyst
Image Analyst 2016-1-22
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 2019-10-9
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 2019-8-11
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 个评论
Image Analyst
Image Analyst 2019-8-12
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.

请先登录,再进行评论。


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

类别

Help CenterFile Exchange 中查找有关 Strategy & Logic 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by