Matlab

Differential Equation In Matlab

Ribbon three dimensional plot:

In this three dimensional plot has different color ribbon, in order to create 3d plot for given function.

Let x^3-y^3

[x,y] = peaks(20);

z =[(x.^3)-(y.^3)];

ribbon(z);

title(‘\bf Ribbon Plot’)

Contour three dimensional plot:

Syntax for the contour plot is

Contour3(x,y,z)

Contour3(z)

Let us consider a function to plot the contour plot

[x,y] = peaks(40);

z = exp(-x.^2-y.^2);

contour3(x,y,z);

title(‘\bf Contour Plot’)

Slice three-dimensional plot:

In order to plot a slice 3d plot we have to know the volumetric data (v) and three dimension coordinates specifications i.e., x,y,z

When you writing a matlab for slice plot when compared with normal 3d plot there will be quite difference between them. i.e., you need to specify each coordinate value. Syntax of slice 3d plot is

slice(x,y,z,v,xslice,yslice,zslice)

slice(v,xslice,yslice,zslice)

Now let us draw a slice for given mathematic equation.

[x,y,z] = meshgrid(-12:.1:12);

v = [exp((x.^2)-(y.^2)-(z.^3))];

xslice = 0.1;

yslice = 5;

zslice = 0;

slice(x,y,z,v,xslice,yslice,zslice)

colorbar

title(‘\bf Slice Plot’)

Differential Equation In Matlab:

Now let solve the differential equation in matlab by considering a simple command diff and pass the functions to solve the equations.

Let’s consider the function f(x)=4x2+3x-2

syms x

f = 4*x^2 + 3*x^(-2);

diff(f)

ans=8*x – 6/x^3

Some rules should be followed while solving differential equation, we can write f'(x) for a first order derivative and f”(x) for a second order derivative.

  1. For any functions f and g and any real numbers a and b are the derivative of the function: h(x) = af(x) + bg(x) with respect to x is given by: h'(x) = af'(x) + bg'(x).
  2. The sum and subtraction rules state that if f and g are two functions, f’ and g’ are their derivatives respectively, then, (f + g)’ = f’ + g’ (f – g)’ = f’ – g’.
  3. The product rule states that if f and g are two functions, f’ and g’ are their derivatives respectively, then, (f.g)’ = f’.g + g’.f.
  4. The quotient rule states that if f and g are two functions, f’ and g’ are their derivatives respectively, then, (f/g)’ = (f’.g – g’.f)/g2.
  5. The polynomial or elementary power rule states that, if y = f(x) = xn , then f’ = n. x(n-1). In this rule the direct outcome is that derivate of any constant is zero i.e., if y = k, any constant, then f’ = 0.
  6. The chain rule states that, the derivative of the function of a function h(x) = f(g(x)) with respect to x is, h'(x)= f'(g(x)).g'(x).
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 This Function is Not Available Error: Tizen OS Logic & Fixes (2026)

Introduction: Encountering the message 'This Function is Not Available' on a Samsung Smart TV is…

3 days ago

How to Use FlexClip AI PowerPoint to Video (Step-by-Step 2026)

We have all been there, you spend hours making a perfect PowerPoint presentation, but you…

5 days ago

Samsung Smart TV Screen Flickering On and OFF: 2026 Diagnostic & Fix Guide

🎓 Technical Learning Module: Display Engineering Verified 2026 👨‍🏫 Instructor: Lakshmi Durga (M.Tech) 🛡️ Oversight:…

3 weeks ago

Samsung Smart TV Remote Not Working: A Technical Analysis of IR & Bluetooth Logic

🎓 Technical Learning Module: Input Logic Verified 2026 Expert Solution 👨‍🏫 Instructor: Rajeshwari (M.Tech) 🛡️…

3 weeks ago

Samsung Smart TV Apps Not Loading: Tizen 9.0 Architecture & Logic Analysis

🎓 Technical Learning Module Verified 2026 Expert Solution 👨‍🏫 Instructor: Rajeshwari (M.Tech) 🛡️ Oversight: Ratan…

2 months ago

Google Spam Update 2025: Impact, Recovery Guide & SpamBrain Explained

Google released a spam update on 26th of August 2025 and this is affecting a…

7 months ago