Skip to content

It creates three separate plots and one combined plot for simple polynomial functions ($y=x^3+2x$, $y=x^2+3x$, etc.), using various markers and colors.

Notifications You must be signed in to change notification settings

Sni180/matlab-basic-function-plots

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

image MATLAB Basic Function Plots This repository contains a simple MATLAB (or Octave) script designed to demonstrate fundamental plotting techniques, data generation, and figure management.

Overview The script generates data for three basic polynomial functions over a defined range and then visualizes these data sets in four separate figures. This is an ideal starting example for users new to MATLAB plotting.

Functions Plotted The script visualizes data for the following three function : 1.A cubic function y = x^3 + 2x - Variable is y1 2.A quadratic function y = x^2 + 3x - Variable is y2
3. A downward-opening quadratic function y = -x^2 - 2x - Variable is y3 The x-range for all plots is 1 to 10 with 10 data points.

Outputs (Figures): The script generates four separate figures: Figure 1: Plot of y1 using red plus signs (r+). Figure 2: Plot of y2 using blue circles (bo). Figure 3: Plot of y3 using black asterisks (k*). Figure 4: A combined plot displaying y_1, y_2, and y_3 on the same axes using the hold on command.

Key Concepts Demonstrated The code illustrates the use of several essential MATLAB commands: clear all and close all: For initializing a clean environment. linspace: To create an evenly spaced vector for the x-axis. figure(N): To create and manage separate plot windows.plot(x, y, 'style'): The core function for 2D plotting, including specifying line/marker styles.xlabel, ylabel, title, grid on: For adding essential plot annotations. hold on: To overlay multiple data series on a single set of axes.

How to RunSave the code provided (or the file main.m if you name it) to your computer: 1.Open MATLAB to the directory where you saved the file. 2.Type the filename (e.g., main) in the command window and press 3.Enter.Matlab>> main Four separate figure windows will appear, showing the various plots.

About

It creates three separate plots and one combined plot for simple polynomial functions ($y=x^3+2x$, $y=x^2+3x$, etc.), using various markers and colors.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages