How to display y=0 in figure

조회 수: 335 (최근 30일)
ly
ly 2016년 1월 22일
답변: EL_DON 2019년 10월 9일
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