Matlab graphing/plotting problem

  • Context: MATLAB 
  • Thread starter Thread starter sara_87
  • Start date Start date
  • Tags Tags
    Matlab
Click For Summary
SUMMARY

The discussion focuses on plotting specific points in MATLAB, specifically the coordinates (8,0), (4,-4), (-4,4), and (-8,0). The user seeks to connect the first two points and the last two points on the same graph. The solution involves creating two arrays for the X and Y coordinates and using the MATLAB plot command to visualize the connections. The complete code provided is: X1=[8 4]; Y1=[0 -4]; X2=[-4 -8]; Y2=[4 0]; plot(X1,Y1,..., X2,Y2);

PREREQUISITES
  • Basic understanding of MATLAB syntax
  • Familiarity with plotting functions in MATLAB
  • Knowledge of coordinate systems
  • Ability to create and manipulate arrays in MATLAB
NEXT STEPS
  • Explore MATLAB's hold on command for adding multiple plots
  • Learn about customizing plots in MATLAB, including colors and markers
  • Investigate MATLAB's legend function for labeling different data series
  • Study MATLAB's grid function to enhance graph readability
USEFUL FOR

Students learning MATLAB, data analysts, and anyone interested in visualizing mathematical functions or datasets using MATLAB plotting capabilities.

sara_87
Messages
748
Reaction score
0

Homework Statement



i have 4 points,
(8,0)
(4,-4)
(-4,4)
(-8,0)
i want to draw a graph of this on MATLAB so that the first to points are joined, the last two points are joined, but i want it on the same graph.
how do i do this? what's the command?
thank you
 
Physics news on Phys.org
Alright, so you're learning to use Matlab... :)
Your first two coordinates are: (8,0) and (4,-4)
These coordinates are in the form (X,Y).
so make an array with your X data and an array with your Y data like this:
X1=[8 4]; Y1=[0 -4];
Then get Matlab to plot it by using the plot command:
plot(X1,Y1)

Do the same for the other pair of coordinates...

Altogether, it will look like this: (just cut and paste.. and it should work)

%start
X1=[8 4]; Y1=[0 -4];
X2=[-4 -8]; Y2=[4 0];

plot(X1,Y1,...
X2,Y2);
%end
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 32 ·
2
Replies
32
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 2 ·
Replies
2
Views
4K