0% found this document useful (0 votes)
35 views3 pages

MATLAB Exercises and Solutions Guide

This document provides 21 problems for solving using MATLAB. Some of the key problems include: 1) Performing operations on matrices such as calculating sums of rows/columns, transposes, and products. 2) Plotting multiple signals (sine waves) on the same graph. 3) Adding transfer functions and plotting outputs. 4) Converting between temperature scales and analyzing datasets using statistics and plots. 5) Solving differential equations using numerical methods for systems like RC circuits, springs, and pendulums.

Uploaded by

Diana Hall
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views3 pages

MATLAB Exercises and Solutions Guide

This document provides 21 problems for solving using MATLAB. Some of the key problems include: 1) Performing operations on matrices such as calculating sums of rows/columns, transposes, and products. 2) Plotting multiple signals (sine waves) on the same graph. 3) Adding transfer functions and plotting outputs. 4) Converting between temperature scales and analyzing datasets using statistics and plots. 5) Solving differential equations using numerical methods for systems like RC circuits, springs, and pendulums.

Uploaded by

Diana Hall
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Problems Statements for MATLAB Exercises

1. Construct any 4*4 matrix, calculate sum of its rows and sum of its columns. Construct transpose of its matrix. If 4*4 matrix was A and its transpose was A, then calculate A + A and A*A. Construct B matrix of 4*4 and calculate A+B and A*B. Calculate the determinant of the resulting matrix (A+B). Now calculate the sum of its (A+B) diagonal elements.

2.

Construct a plot between X, Y1 and Y2 on single plot where X = (0, 2) with increment of /10 Y1 = sin (x) Y2 = sin (x - 0.25)

3.

Create the following transfer functions: Y1 = 50 / (s2 + 5s +30) Y2 = (2s2 + 3s) / (4s2 + 3s) And add these two transfer functions.

4. 5.

Develop a MATLAB program to convert temperature reading form oC to oF and vice-versa. Generate a large chunk of data (use Array/Clusters as you desire) and compute Mean, Standard Deviation and Variance, Mode, Histogram, Moment around the mean, RMS etc.

6.

Design your own problems on (Validate the results you obtained) a. Differentiation b. Integration

7. 8.

Plot all the standard signals like step, ramp, impulse and sinusoids. Construct a series of numbers: A = 1 3 5 7 9 11 13 15 17 19 21 B = 50 48 46 44 42 ................ 2

9.

Develop a MATLAB program to add all the integer number from 1 to 10.

10. Develop a MATLAB program to add all the odd numbers from 1 to 101, both numbers are inclusive. 11. The model of RC circuit shown in figure 1. Can be found from Kirchhoffs voltage law and conservation of change. Suppose the value of RC is 0.1 second. Use a numerical method to find the free response for the case where the applied voltage v is 0 and the initial capacitor voltage is y (0) =2 volts.

fig 1. An RC circuit 12. Consider an RC circuit shown in fig 1. Where RC=0.1 second suppose that the applied voltage oscillates sinusoidally with a period P and decaying amplitude. The voltage is given by Thus the voltage amplitude will be less than 2 percent of its initial value, or essentially 0 or t 41 find and plot the output voltage y(t) for the case (i). 1= 0.3 seconds, P=2 seconds (ii). 1= 0.05 seconds, P=0.03 seconds 13. Obtain the convolution of the following [ ] [ (i) [ ] [ (ii) [ ] [ (iii) ] ] ]

14. Consider a mechanical system with equation where m=1kg, b=3 N-sec/m and k=2N/m. Assume that at t=0 , x(0)=0.1m and (0)=0.05m/sec. Obtain motion of mass m subjected to initial condition. 15. Obtain the unit step and impulse response of the system subjected to the initial condition. Also plot the responses. ( ) ( )( ) , ( )=( ) 16. Using numerical method (ODE), obtain free response of an RC circuit (RC voltage v is zero and initial capacitor voltage is y(0)=2V, RC=0.1s. 17. Use MATLAB to compute and plot the solution of following equation )where applied

18. Use MATLAB to compute and plot the solution of following equation 19. Consider the pendulum shown in the figure. Equation of motion for this pendulum is + Suppose L=1m and g=9.8m/s2. Use matlab to solve this equation for (t) if (0)=.05rad and

L g

20. Plot the position and velocity of a mass with spring and damping system, having parameters m=2, c=3 and k=7. The applied force is u=35, y(0)=2 and (0)=-3 21 a) Generate an overlay plot for plotting three lines

0<t<2 I. the plot command II. the hold command III. the line command b) Use the function for plotting x-y data plotting the following functions I. 0<t<10 II. 0<t<2

NOTE: Other problems will be emailed soon.

Common questions

Powered by AI

MATLAB can be used to simulate the free response of an RC circuit by setting the initial conditions and using a numerical method such as the ODE solver. Given an RC constant of 0.1 seconds and an initial capacitor voltage y(0) = 2V, set up the differential equation RC*dy/dt = -y with applied voltage v = 0. Use the MATLAB ode45 function to numerically solve this ODE over a specified time span to observe the voltage response .

To perform convolution on discrete sequences in MATLAB, define the discrete sequences using vectors. Use the conv() function to compute their convolution, which mathematically combines the two sequences to generate a convolved signal. This operation is foundational in digital signal processing for assessing the output response of linear time-invariant systems given an input sequence .

In MATLAB, write a function that takes a temperature and unit (Celsius or Fahrenheit) as inputs. Define the conversion formulas: °F = °C * 9/5 + 32 for Celsius to Fahrenheit and °C = (°F - 32) * 5/9 for Fahrenheit to Celsius. Implement the switch-case structure to determine which conversion to apply. This program enables bi-directional temperature conversion by utilizing MATLAB's robust processing capabilities .

In MATLAB, standard signals can be constructed using functions like step(), ramp(), impulse(), and sin(). For visualization, create time vectors, use these functions to generate signal data, and then plot them using MATLAB plotting functions such as plot(). To enhance the visualization, use the hold on command to overlay multiple signals on a single graph. The command subplot() can also be employed to create a collective representation of different signals in a single figure window .

Develop MATLAB functions to solve differentiation and integration problems. Use diff() for numerical differentiation and int() or trapz() for symbolic or numerical integration, respectively. Validate results by comparing them against analytical solutions, plotting functions and derivatives, or evaluating integrals over known bounds. This approach allows comprehensive solution checking and increases understanding of underlying mathematical principles .

To compute statistical measures in MATLAB, first generate a data set using constructs like arrays or matrices. Then, use the functions mean(data) for mean, std(data) for standard deviation, and var(data) for variance. Additionally, histogram(data) can be used for distribution visualization, and rms(data) for the root mean square value. MATLAB's built-in functions make it efficient to extract these statistical properties from large data sets .

In MATLAB, to calculate and plot the velocity and position of a mass-spring-damping system, define system parameters m = 2, c = 3, k = 7, and external force u = 35. Set up the second-order ODE m*y'' + c*y' + k*y = u. Use initial conditions y(0) = 2, y'(0) = -3. Solve using the ode45 function, which numerically integrates the system's differential equation from the initial conditions over a defined time span. Use plot commands to visualize both y(t) and y'(t).

To add and plot transfer functions in MATLAB, define the transfer functions Y1 = 50/(s² + 5s + 30) and Y2 = (2s² + 3s)/(4s² + 3s) using tf syntax. Use tfaddition = Y1 + Y2 to add them. Apply the bode(tfaddition) or step(tfaddition) commands to plot frequency response or step response. MATLAB’s control systems toolkit simplifies operations on transfer functions, enabling easy addition and visualization .

To calculate the determinant of a matrix resulting from the sum of two 4x4 matrices in MATLAB, first construct the matrices A and B. Use the command sum(A) and sum(B) to calculate the sum of their rows and columns, respectively. Then, use C = A + B to form the resulting matrix. Finally, use det(C) to find the determinant of matrix C .

To solve the equation of motion for a pendulum in MATLAB, define the pendulum's parameters: L = 1m, g = 9.8m/s², θ(0) = 0.05 radian. Set up the differential equation θ'' + (g/L)sin(θ) = 0. Discretize the time span and use ode45 or similar ODE solvers to compute θ(t) over time. Specify initial conditions in the solver call. MATLAB will solve the nonlinear ODE using numerical methods and allow you to plot θ over time for analysis .

You might also like