0% found this document useful (0 votes)
6 views1 page

solving ode using analytical method

This document outlines a MATLAB script for solving and plotting an ordinary differential equation (ODE). It includes steps for setting up the workspace, defining symbolic variables, solving the ODE, and creating a plot with labels. The specific ODE solved is dy/dt = 0.01*sin(y)*cos(t) with an initial condition of y(0)=0.05.

Uploaded by

Sai Kiran
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

solving ode using analytical method

This document outlines a MATLAB script for solving and plotting an ordinary differential equation (ODE). It includes steps for setting up the workspace, defining symbolic variables, solving the ODE, and creating a plot with labels. The specific ODE solved is dy/dt = 0.01*sin(y)*cos(t) with an initial condition of y(0)=0.05.

Uploaded by

Sai Kiran
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

% --- 1.

SETUP: Clean Workspace & Figure ---


clc;
clear;
close all;

% --- 2. SYMBOLIC DEFINITION: Tell MATLAB what's symbolic ---


% Syntax: syms dependent_var(independent_var)
% What to change: 'y' and 't' to match YOUR ODE's variables.
syms y(t)

% --- 3. SOLVE: Define and solve the ODE ---


% Syntax: solution_var(independent_var) = dsolve(ODE_equation, condition1, ...,
independent_var_name)
% What to change:
% - 'diff(y)' for dy/dt (or diff(y,t,2) for d^2y/dt^2, etc.)
% - The right side of the ODE equation.
% - The initial/boundary condition (e.g., y(0)==value, diff(y,t)==value).
y(t) = dsolve(diff(y) == 0.01*sin(y)*cos(t), y(0)==0.05);

% --- 4. PLOT: Prepare for numerical plotting ---


% Syntax: numerical_independent_var_range = start:step:end;
% What to change: The range and step size for your independent variable.
t= 0:0.1:1;

% --- 5. PLOT: Create the graph ---


% Syntax: plot(x_data, y_data, 'LineSpec', ...);
% What to change:
% - 't' for x-axis data.
% - 'y(t)' to evaluate your symbolic solution numerically.
% - Line properties ('r', 'LineWidth', etc.)
plot(t, y(t), 'r', 'LineWidth', 2);

% --- 6. LABELS: Add descriptions to your plot ---


xlabel('t');
ylabel('y');
% (Optional: add a title)
% title('Analytical Solution of My ODE');
grid on;

You might also like