SlideShare a Scribd company logo
1 of 2
Download to read offline
1. Create a file name with DiffEqn.m with the following code
function dx=DiffEqn(t,x)
m=10;
k=100;
b=1;
x1=x(1);
x2=x(2);
dx1=x2;
dx2=(1/m)*(-k*x1-b*x2);
dx=[dx1;dx2];
2. Create another file for running the differential equation with all the given conditions.
%using ode solver we can solve the given differential equation.
[t,x]=ode45(@DiffEqn,[1,100],[10,0]);
%plotting the final result t vs dx/dt
plot(t,x(:,1));
Solution
1. Create a file name with DiffEqn.m with the following code
function dx=DiffEqn(t,x)
m=10;
k=100;
b=1;
x1=x(1);
x2=x(2);
dx1=x2;
dx2=(1/m)*(-k*x1-b*x2);
dx=[dx1;dx2];
2. Create another file for running the differential equation with all the given conditions.
%using ode solver we can solve the given differential equation.
[t,x]=ode45(@DiffEqn,[1,100],[10,0]);
%plotting the final result t vs dx/dt
plot(t,x(:,1));

More Related Content

Similar to 1. Create a file name with DiffEqn.m with the following codefuncti.pdf

Create a class named Point that represent points in in three dimension.docx
Create a class named Point that represent points in in three dimension.docxCreate a class named Point that represent points in in three dimension.docx
Create a class named Point that represent points in in three dimension.docx
earleanp
 
lecrfigfdtj x6 I f I ncccfyuggggrst3.pdf
lecrfigfdtj x6 I f I ncccfyuggggrst3.pdflecrfigfdtj x6 I f I ncccfyuggggrst3.pdf
lecrfigfdtj x6 I f I ncccfyuggggrst3.pdf
HebaEng
 
Arrays and structures
Arrays and structuresArrays and structures
Arrays and structures
Mohd Arif
 

Similar to 1. Create a file name with DiffEqn.m with the following codefuncti.pdf (13)

A Generalized Metric Space and Related Fixed Point Theorems
A Generalized Metric Space and Related Fixed Point TheoremsA Generalized Metric Space and Related Fixed Point Theorems
A Generalized Metric Space and Related Fixed Point Theorems
 
Explanation on Tensorflow example -Deep mnist for expert
Explanation on Tensorflow example -Deep mnist for expertExplanation on Tensorflow example -Deep mnist for expert
Explanation on Tensorflow example -Deep mnist for expert
 
Excel macro for solving a polynomial equation
Excel macro for solving a polynomial equationExcel macro for solving a polynomial equation
Excel macro for solving a polynomial equation
 
The chain rule
The chain ruleThe chain rule
The chain rule
 
Matlab differential
Matlab differentialMatlab differential
Matlab differential
 
1st order differential equations
1st order differential equations1st order differential equations
1st order differential equations
 
Tutorial 2
Tutorial     2Tutorial     2
Tutorial 2
 
Create a class named Point that represent points in in three dimension.docx
Create a class named Point that represent points in in three dimension.docxCreate a class named Point that represent points in in three dimension.docx
Create a class named Point that represent points in in three dimension.docx
 
Online Maths Assignment Help
Online Maths Assignment HelpOnline Maths Assignment Help
Online Maths Assignment Help
 
The Ring programming language version 1.5.3 book - Part 25 of 184
The Ring programming language version 1.5.3 book - Part 25 of 184The Ring programming language version 1.5.3 book - Part 25 of 184
The Ring programming language version 1.5.3 book - Part 25 of 184
 
lecrfigfdtj x6 I f I ncccfyuggggrst3.pdf
lecrfigfdtj x6 I f I ncccfyuggggrst3.pdflecrfigfdtj x6 I f I ncccfyuggggrst3.pdf
lecrfigfdtj x6 I f I ncccfyuggggrst3.pdf
 
Arrays and structures
Arrays and structuresArrays and structures
Arrays and structures
 
Programming for Mechanical Engineers in EES
Programming for Mechanical Engineers in EESProgramming for Mechanical Engineers in EES
Programming for Mechanical Engineers in EES
 

More from KUNALHARCHANDANI1

Static Keyword Static is a keyword in C++ used to give special chara.pdf
  Static Keyword Static is a keyword in C++ used to give special chara.pdf  Static Keyword Static is a keyword in C++ used to give special chara.pdf
Static Keyword Static is a keyword in C++ used to give special chara.pdf
KUNALHARCHANDANI1
 
Which of the following would be a description of a system unitA c.pdf
Which of the following would be a description of a system unitA c.pdfWhich of the following would be a description of a system unitA c.pdf
Which of the following would be a description of a system unitA c.pdf
KUNALHARCHANDANI1
 
Water is a polar inorganic solvent. Benzene is a nonpolar organic so.pdf
Water is a polar inorganic solvent. Benzene is a nonpolar organic so.pdfWater is a polar inorganic solvent. Benzene is a nonpolar organic so.pdf
Water is a polar inorganic solvent. Benzene is a nonpolar organic so.pdf
KUNALHARCHANDANI1
 
viruses which have single strande DNA in their genome come under cat.pdf
viruses which have single strande DNA in their genome come under cat.pdfviruses which have single strande DNA in their genome come under cat.pdf
viruses which have single strande DNA in their genome come under cat.pdf
KUNALHARCHANDANI1
 
This word problem is about a triangle whose perimeter is 47 miles. S.pdf
This word problem is about a triangle whose perimeter is 47 miles. S.pdfThis word problem is about a triangle whose perimeter is 47 miles. S.pdf
This word problem is about a triangle whose perimeter is 47 miles. S.pdf
KUNALHARCHANDANI1
 

More from KUNALHARCHANDANI1 (20)

The metal will undergo oxidation forming metal ion and releasing .pdf
 The metal will undergo oxidation forming metal ion and releasing .pdf The metal will undergo oxidation forming metal ion and releasing .pdf
The metal will undergo oxidation forming metal ion and releasing .pdf
 
Static Keyword Static is a keyword in C++ used to give special chara.pdf
  Static Keyword Static is a keyword in C++ used to give special chara.pdf  Static Keyword Static is a keyword in C++ used to give special chara.pdf
Static Keyword Static is a keyword in C++ used to give special chara.pdf
 
Sr2+ is most likely to substitute for Ca2+ becaus.pdf
                     Sr2+ is most likely to substitute for Ca2+ becaus.pdf                     Sr2+ is most likely to substitute for Ca2+ becaus.pdf
Sr2+ is most likely to substitute for Ca2+ becaus.pdf
 
may be that peak id due to presence of alkyl gro.pdf
                     may be that peak id due to presence of  alkyl gro.pdf                     may be that peak id due to presence of  alkyl gro.pdf
may be that peak id due to presence of alkyl gro.pdf
 
There should only have one singlet resonance for .pdf
                     There should only have one singlet resonance for .pdf                     There should only have one singlet resonance for .pdf
There should only have one singlet resonance for .pdf
 
the link is not working can u pls write questions.pdf
                     the link is not working can u pls write questions.pdf                     the link is not working can u pls write questions.pdf
the link is not working can u pls write questions.pdf
 
The one have higher value of E(cell) is acting as.pdf
                     The one have higher value of E(cell) is acting as.pdf                     The one have higher value of E(cell) is acting as.pdf
The one have higher value of E(cell) is acting as.pdf
 
Nicotine has a molecular formula of C10H14N2 .pdf
                     Nicotine has a molecular formula of C10H14N2     .pdf                     Nicotine has a molecular formula of C10H14N2     .pdf
Nicotine has a molecular formula of C10H14N2 .pdf
 
i have it .pdf
                     i have it                                      .pdf                     i have it                                      .pdf
i have it .pdf
 
HClO4 in aqueous medium ionizes as Hydrogen(+1)ca.pdf
                     HClO4 in aqueous medium ionizes as Hydrogen(+1)ca.pdf                     HClO4 in aqueous medium ionizes as Hydrogen(+1)ca.pdf
HClO4 in aqueous medium ionizes as Hydrogen(+1)ca.pdf
 
Which of the following would be a description of a system unitA c.pdf
Which of the following would be a description of a system unitA c.pdfWhich of the following would be a description of a system unitA c.pdf
Which of the following would be a description of a system unitA c.pdf
 
Water is a polar inorganic solvent. Benzene is a nonpolar organic so.pdf
Water is a polar inorganic solvent. Benzene is a nonpolar organic so.pdfWater is a polar inorganic solvent. Benzene is a nonpolar organic so.pdf
Water is a polar inorganic solvent. Benzene is a nonpolar organic so.pdf
 
viruses which have single strande DNA in their genome come under cat.pdf
viruses which have single strande DNA in their genome come under cat.pdfviruses which have single strande DNA in their genome come under cat.pdf
viruses which have single strande DNA in their genome come under cat.pdf
 
This word problem is about a triangle whose perimeter is 47 miles. S.pdf
This word problem is about a triangle whose perimeter is 47 miles. S.pdfThis word problem is about a triangle whose perimeter is 47 miles. S.pdf
This word problem is about a triangle whose perimeter is 47 miles. S.pdf
 
CH4 + 2O2 -- CO2 + 2H2O note CH4 combustion is.pdf
                     CH4 + 2O2 -- CO2 + 2H2O  note CH4 combustion is.pdf                     CH4 + 2O2 -- CO2 + 2H2O  note CH4 combustion is.pdf
CH4 + 2O2 -- CO2 + 2H2O note CH4 combustion is.pdf
 
SbAspnSolutionSbAspn.pdf
SbAspnSolutionSbAspn.pdfSbAspnSolutionSbAspn.pdf
SbAspnSolutionSbAspn.pdf
 
Carbon 2 is where D and L differ for all sugars. .pdf
                     Carbon 2 is where D and L differ for all sugars. .pdf                     Carbon 2 is where D and L differ for all sugars. .pdf
Carbon 2 is where D and L differ for all sugars. .pdf
 
Program to print the Diamond Shape -#include stdio.h int ma.pdf
Program to print the Diamond Shape -#include stdio.h int ma.pdfProgram to print the Diamond Shape -#include stdio.h int ma.pdf
Program to print the Diamond Shape -#include stdio.h int ma.pdf
 
Part D option 4 is answerUnless untill they are exposed by some me.pdf
Part D option 4 is answerUnless untill they are exposed by some me.pdfPart D option 4 is answerUnless untill they are exposed by some me.pdf
Part D option 4 is answerUnless untill they are exposed by some me.pdf
 
Isomers which have their atoms connected in the same sequence but di.pdf
Isomers which have their atoms connected in the same sequence but di.pdfIsomers which have their atoms connected in the same sequence but di.pdf
Isomers which have their atoms connected in the same sequence but di.pdf
 

Recently uploaded

Recently uploaded (20)

Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 

1. Create a file name with DiffEqn.m with the following codefuncti.pdf

  • 1. 1. Create a file name with DiffEqn.m with the following code function dx=DiffEqn(t,x) m=10; k=100; b=1; x1=x(1); x2=x(2); dx1=x2; dx2=(1/m)*(-k*x1-b*x2); dx=[dx1;dx2]; 2. Create another file for running the differential equation with all the given conditions. %using ode solver we can solve the given differential equation. [t,x]=ode45(@DiffEqn,[1,100],[10,0]); %plotting the final result t vs dx/dt plot(t,x(:,1)); Solution 1. Create a file name with DiffEqn.m with the following code function dx=DiffEqn(t,x) m=10; k=100; b=1; x1=x(1); x2=x(2); dx1=x2; dx2=(1/m)*(-k*x1-b*x2); dx=[dx1;dx2]; 2. Create another file for running the differential equation with all the given conditions. %using ode solver we can solve the given differential equation. [t,x]=ode45(@DiffEqn,[1,100],[10,0]);
  • 2. %plotting the final result t vs dx/dt plot(t,x(:,1));