Info

This question is closed. Reopen it to edit or answer.

Tracking a square wave with an analytical function

4 views (last 30 days)
A
A on 24 Jun 2011
Closed: Sabin on 6 Feb 2023
I have created a square wave (voltage schedule) in Excel, that I want to "track" with an analytical function.
The idea is to simulate a DC motor that has step changes in voltage.
R = 2;
L = 1e-3;
Ca = 1e-5;
% Continuous time voltage sched
Volt_vec = xlsread('voltage schedule.xlsx','C:C');
% Initial current
I_L_0 = 0;
% Initial voltage
V_C_0 = 0;
V_In = Volt_vec;
t = 0:.0001:.01;
alpha = R/2/L;
omega_0=sqrt(1/L/Ca);
zeta=alpha/omega_0;
omega_d=omega_0*sqrt(1-zeta^2);
A=[1, 0;
-alpha, omega_d]; %
b=[V_C_0-V_In;
I_L_0/Ca];
x=A\b;
V = exp(-alpha*t).*(x(1)*cos(omega_d*t)+x(2)*sin(omega_d*t))+V_In;
The voltage vector is similar to:
t = 0 to .001, V = 85
t = .001 to .004, V = 30
t = .004 to .01, V = 65 etc.
Just a square wave with varying lengths of the step.
Right now I just read in the voltage vector and use it as the step input (V_In), and it doesn't work due to matrix dimensions issues.
I need the final value (t,v) before the next step jump in voltage to serve as the initial conditions for the following case.

Answers (0)

This question is closed.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!