How to display y=0 in figure

265 visualizzazioni (ultimi 30 giorni)
ly il 22 Gen 2016
Risposto: EL_DON il 9 Ott 2019
Hi,
I want to display like the figure.
How to display (y=0) like this.
2 CommentiMostra NessunoNascondi Nessuno
Thorsten il 22 Gen 2016
Modificato: Thorsten il 22 Gen 2016
What exactly is your problem? What have you done so far? Please provide the code you have tried to generate the figure.
ly il 22 Gen 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;

Accedi per commentare.

Risposta accettata

Ilham Hardy il 22 Gen 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 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
ly il 22 Gen 2016
Modificato: ly il 22 Gen 2016
No, it isn't a plotted curve. It is a part of figure.
There are many examples about it.

Accedi per commentare.

Più risposte (4)

Image Analyst il 22 Gen 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;
0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

EL_DON il 9 Ott 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';
0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

lasindu madushan il 11 Ago 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 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
Image Analyst il 12 Ago 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.

Accedi per commentare.

Steven Lord il 12 Ago 2019
As of release R2015b you can set the XAxisLocation property of the axes to 'origin'.
0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

Categorie

Scopri di più su Specifying Target for Graphics Output in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by