MATLAB Archives | Electricalvoice

MATLAB for Loop Examples

A MATLAB for loop is a repetition control structure that allows you to efficiently write a loop that needs to execute a specific number of times. The MATLAB for loop syntax is given as for index = values <program statements> … end MATLAB for loop Examples 1. Write a program to display numbers from 1 … Read more

MATLAB Program for Kalman Filter

Q. To estimate the positions and velocity of an object using Kalman Filter in MATLAB when a set of measurements and control inputs are available. Please read about Kalman Filter and Extended Kalman Filter. Program %==============================KALMAN FILTER ============================== %To estimate position ‘X’ and velocity ‘Xdot’ of a moving object when the %measurement of position ‘Y’ and … Read more

MATLAB Program to Obtain Transfer Function from Data

Q. Obtain the transfer function from the following data Program %Program to Obtain Transfer Function from Data %provided by electricalvoice.com clc clear all %obtain transfer matrix A=[-5 1;-6 0] B=[1;2] C=[2 1] D=[0] [num, den]=ss2tf(A,B,C,D) printsys(num,den) Q. Obtain the transfer function from the following data Program %Program to Obtain Transfer Function from Data %provided by … Read more

MATLAB Program for finding Error Coefficients

Q. The open-loop transfer function of a unity feedback control system is given by Find error coefficients (a). Kp  (b). Kv  (c). Ka Program % program for calculation of error coefficients % provided by electricalvoice.com clc clear all numg=10 deng=[1 6 10] %step input %calculation of error coefficient kp G=tf(numg, deng) kp=dcgain(G) Ess=1/(1+kp) %ramp input … Read more

MATLAB Program for Determining Time response of Transfer function

Q. Determine the time response for the following transfer function using MATLAB. Answer. First of all simplifying numerator(num) and denominator(den) of the transfer function respectively as num = s+2 den = s2+2s+2 Program % program for Determining Time response of Transfer function % provided by electricalvoice.com clc clear all num=[1 2]; den=[1 2 2]; sys5=tf(num,den) load … Read more

MATLAB Program for finding Poles & Zeroes of Transfer Function

Q. The transfer function of a system is given below Determines the poles and zeroes and show the pole-zero configuration in s-plane using MATLAB. First of all simplifying numerator(p1) and denominator(q1) of the transfer function respectively as p1=8s2+56s+96 q1=s4+4s3+9s2+10s Program % program for finding poles and zeroes of a transfer function % provided by electricalvoice.com clc … Read more

MATLAB Program for Plotting Two sine waves Connected Together

MATLAB Program for plotting Two sine waves connected together, one of which has twice the frequency of other. Program %Two sine waves connected together,one of which has twice the frequency of other %provided by electricalvoice.com clc clear all fr= input(‘Enter frequency in Hz:’); stptime = input(‘Enter Stop time in Second:’); frad = 2*pi*fr; t = … Read more

MATLAB Program for Drawing two circles one having radius twice the other

Using Matlab Draw two sine waves connected together, one of which has twice the frequency of other. Program %Program Code for Drawing two circles one having radius twice the other %provided by electricalvoice.com clc clear all x=input(‘Enter x-cordinate of center of circle:’); y=input(‘Enter y-cordinate of center of circle:’); r=input(‘Enter radius of circle:’); ang=0:0.01:2*pi; xp=r*cos(ang); yp=r*sin(ang); … Read more

error: Content is protected !!