Matlab

Multiple Functions On the Same Graph

Multiple Functions On Same Graph:

In matlab we can draw multiple functions on the same graph by considering some basic colors.

Colors                        code

White                           w

Blue                              b

Cyan                             c

Black                            k

Green                           g

Magenta                       m

Yellow                          y

Red                                r

Let us consider a script for two polynomials.

g(x)= 4x4+3x3+2x2+2x+9

h(x)=4x3+9x+2

x=[-15:0.01:15];

g=4*x.^4 + 3* x.^3 + 2 * x.^2 + 2 * x + 9

h=4 * x.^3 + 9 * x + 2;

Plot(x, g, ‘k’, x, h, ‘r’)

When you run the file you will output as shown in below.

AXIS SETTING:

In order to provide minimum and maximum values for x and y axis by considering the axis command. With axis command allow us to set axis scale.

Syntax will be:

axis ([xmin  xmax  ymin  ymax])

FOR GENERATING SUBPLOT:

Subplot in matlab is used to divide the current figure and allow us to plot multiple figures in the m rows and n column.

Syntax for matlab

Subplot (m, n, p)

Let us consider a example for plotting

In order to plot the income in the top half of the figure and outgo in the bottom half of the figure,

      income = [3.2 4.1 5.0 5.6];
outgo = [2.5 4.0 3.35 4.9];
subplot(2,1,1); plot(income)
subplot(2,1,2); plot(outgo)

Below figure shows four subplot regions

The following combinations produce asymmetrical arrangements of subplots.

 subplot(2,2,[1 3])

subplot(2,2,2)

subplot(2,2,4)

Rajeshwari Chiluveru

Rajeshwari (M.Tech) is the Technical Education Director at WebVidyalayam. She focuses on translating high-level systems engineering into accessible technology courses.

Share
Published by
Rajeshwari Chiluveru

Recent Posts

Samsung TV Red Light Blinking? 4 Fixes (2026 Power Logic Hub)

User Problem Scenario: The Red Light "Panic" You press the power button on your Samsung…

2 weeks ago

Samsung TV Not Connecting to WiFi: 2026 Easy Fix Guide

Introduction: I Know the Feeling "We’ve all been there. You sit down to watch your…

2 weeks ago

Samsung TV Restarting During Diagnosis? Fix the Reboot Loop Fast

User Problem Scenario: The "Diagnosis Loop" Paradox Imagine you notice your apps are slow. You…

2 weeks ago

Samsung TV Optimize Now Not Working? (2026 Fix: Greyed Out, Stuck or Not Responding)

🎓 Technical Module: Memory Maintenance Logic Module: WV-OS-307 Verified 2026 👨‍🏫 Instructor: Vangari Divya (M.Tech)…

3 weeks ago

Samsung Smart Hub Test Failed? (2026 Fix: DNS, ISP Block & Authentication Error)

 Introduction: The Setup Paradox "There is a specific moment of frustration for every Samsung Smart…

3 weeks ago

Samsung TV Picture Test Not Working? 4 Technical Recovery Fixes

Introduction: Lab Diary & Experience "When your Samsung TV screen begins to flicker or show…

3 weeks ago