Project 1 - Data Handling and Interpolation
1-Following Matlab script have been attached below.
For output user have to give two input in dialouge box; mass and spring constant.
Comparision between Ode45 and Ode23 :
- 'ode45' is a more accurate and versatile solver that uses a variable step size. It can handle both stiff and non-stiff differential equations. For this reason, 'ode45' is generally more accurate than 'ode23', but it may be computationally more expensive.
- 'ode23' is a less accurate solver compared to 'ode45' but is more efficient for non-stiff problems. It uses a fixed step size and performs a second-order interpolation between the steps, which leads to less accuracy in the solution compared to 'ode45'.
- In the plot, you will observe that the solutions obtained from 'ode45' are generally smoother and closer to the actual behavior of the simple harmonic oscillator, while 'ode23' may exhibit some oscillations or deviations due to its lower accuracy.
- If the system is stiff (large stiffness constant 'k'), 'ode45' may require smaller step sizes, leading to increased computational cost, while 'ode23' can still handle the problem efficiently with a fixed step size.
3- Following Matlab script have been attached below with one of the result figure.
User have to give input inside the plot through a cross hair for global maxima and local maxima.
2- Following Matlab scripts have been attached below.
4-Contour Command- The "contour" command in MATLAB is used to create contour plots, which are graphical representations of 2D data, typically displayed as contour lines. These lines connect points of equal values, forming curves that help visualize the variation of a function over a 2D domain. Contour plots are commonly used to visualize functions of two variables and are particularly useful for displaying data with smooth and continuous variations.
The basic syntax for the "contour" command is:
contour(x,y,z).
An example have been attached as a Matlab file below to create a contour plot for f(x,y)=x^2+y^2.