Professional Documents
Culture Documents
Matlab Assingment
Matlab Assingment
SUBMIT TO
MAM AYESHA
SUBMIT BY
AIMAN NAVEED
DEPARTMENT
BS-MATHEMATICS
COURSE TITLE
COMPUTING TOOLS FOR MATHEMATICIANS
COURSE CODE
MATH-207
TOPIC
TWO-DIMENSIONAL PLOT
SUBMISSION DATE
20TH MAY,2024
1. Data Preparation: First, you need data to plot. This could be experimental data,
mathematical functions, or any other form of numerical data.
2. Creating the Plot: Once you have your data, you can use MATLAB's plot function to
create the plot. The basic syntax for the plot function is:
plot (x , y )
3. Customizing the Plot (Optional): You can customize the plot by adding labels,
titles, legends, grid lines, changing line styles or colors, adjusting axis limits, and so on.
For example:
xlabel('X-axis label')
ylabel('Y-axis label')
title('Plot Title')
legend('Data 1', 'Data 2')
grid on
4. Displaying the Plot: To display the plot, use the show function:
Show
This code will plot a sine wave on a two-dimensional graph with labeled axes and a title. You
can modify the data and customize the plot according to your specific requirements.
1. Line Plot:
Function: plot
Description: The most basic type of plot, where data points are connected by lines.
Useful for showing trends over time or across categories
Example:
x = 1:10;
y = rand(1,10);
plot(x, y);
2. Bar Graph:
Function: bar
Description: Uses bars to represent data. Useful for comparing quantities across
categories.
Example:
y = [10, 20, 30, 40];
bar(y);
3. Area Plot:
Function: area
Description: Similar to a line plot but fills the area under the line. Useful for showing
cumulated totals over time.
Example:
x = 1:10;
y = cumsum(rand(1,10));
area(x, y);
4. Pie Chart:
Function: pie
Description: Displays data as slices of a pie. Useful for showing proportions of a whole
Example:
y = [1, 2, 3, 4];
pie(y);
5. Stem Plot:
Function: stem
Description: Similar to a line plot but uses stems from the x-axis to the data points.
Useful for showing discrete data.
Example:
x = 1:10;
y = rand(1,10);
stem(x, y);
6. Histogram:
Function: histogram
Description: Displays the distribution of a dataset by grouping data into bins.
Example:
data = randn(1,1000);
histogram(data);
Line Specifiers:
Line specifiers are optional and can be used to define the style and color of the line and
the type of markers (if markers are desired). The line style specifiers are:
blue b black k
cyan c white w