Borrar filtros
Borrar filtros

How to generate piecewise periodic function in Simulink?

3 visualizaciones (últimos 30 días)
Niels Visser
Niels Visser el 10 de Sept. de 2022
Respondida: Aasha el 10 de Sept. de 2022
For a project I try to simulate backlash behaviour. Simulink provides a built-in function 'backlash' that simulates the effect for so-called friction-controlled backlash. This means that whenever input is reversing direction, output remains constant. However, for my project I would like to simulate so-called 'inertia-controlled' backlash phenemona. Here, the output (load) has some velocity during seperation between motor (input) and load. More specific, the load reaches maximum velocity at $\phi =n \pi$.
The output signal,for the above, was easily modelled with a function handle, however I wish to model the same effect in Simulink that transforms the input sine wave to the correct output wave for multiple periods. I used the MATLAB function block with a sine wave as input $u(t)$. For one period, the output should take the following values:
Utilizing an if-else statement in MATLAB function block showed insufficient results since the function block only takes the values of $u(t)$ into account. So my question is: how can I construct a MATLAB function block that only takes the source $u(t)=Asin(\omega t)$ as input and constructs the required output for multiple period of input wave? Is it possible to use repmat(y(t),1,1) in the function block? If so, how to implement?
clear all; clc;
b = 0.0004; %backlash size
A = 0.0015; %input amp
phi = 0.00190662; %closing angle
freq = 100; %input freq
w = 2*pi*freq;
T = 2*pi/w;
x = linspace(0,T,10);
f = @(x) [(w*A*x - b/2) .*(x>=0 & x<phi)...
+ (A*sin(w*x) + b/2 ) .*(x>phi & x<T/2)...
+ (w*A*cos(w*T/2).*(x - T/2) + b/2) .*(x>T/2 & x<T/2+phi)...
+ (A*sin(w*x) - b/2) .*(x>T/2+phi & x<=T)];
x = linspace(0,T,1000);
intvl = [0,2*T];
pfx = repmat(f(x),1,diff(intvl)/(T));
px = linspace(intvl(1),intvl(2),length(pfx));
plot(px, pfx, 'LineWidth', 2)
grid on

Respuestas (1)

Aasha
Aasha el 10 de Sept. de 2022
clear all; clc;
b = 0.0004; %backlash size
A = 0.0015; %input amp
phi = 0.00190662; %closing angle
freq = 100; %input freq
w = 2*pi*freq;
T = 2*pi/w;
x = linspace(0,T,10);
f = @(x) [(w*A*x - b/2) .*(x>=0 & x<phi)...
+ (A*sin(w*x) + b/2 ) .*(x>phi & x<T/2)...
+ (w*A*cos(w*T/2).*(x - T/2) + b/2) .*(x>T/2 & x<T/2+phi)...
+ (A*sin(w*x) - b/2) .*(x>T/2+phi & x<=T)];
x = linspace(0,T,1000);
intvl = [0,2*T];
pfx = repmat(f(x),1,diff(intvl)/(T));
px = linspace(intvl(1),intvl(2),length(pfx));
plot(px, pfx, 'LineWidth', 2)
grid on

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by