## How to use SetCustomExcite for a shifted signal?

How to use openEMS. Discussion on examples, tutorials etc

Moderator: thorsten

jjmaloss
Posts: 4
Joined: Wed 08 Apr 2020, 04:45

### How to use SetCustomExcite for a shifted signal?

Hi,

I am trying to add shifted signals of type sin(ω(σ-|t|)) in [-σ,σ] and 0 elsewhere. I call this function Umin(t). I am using SetCustomExcite. The issue is that these pulses *are shifted* in time. For example, I would like to perform a simulation where I consider say Umin(t-σ) + Umin(t+3σ) (two isolated pulses). To define Umin(t+3σ), I tried to use the following string 'if(2σ<t<4σ,sin(ω(σ-|t-3σ|),0)' where ω, σ are hard-coded (no conversion from variable to string). I noticed that I got a similar behaviour to 'if(t<4σ,sin(ω(σ-|t-3σ|),0)' and thus the first inequality is not met. However, I get no syntax error. If I try (t>2σ)&(t<4σ) (the AND boolean function ), I get a syntax error without telling me what is wrong.

Am I missing something?

Thank you for the help.

jjmaloss
Posts: 4
Joined: Wed 08 Apr 2020, 04:45

### Re: How to use SetCustomExcite for a shifted signal?

Actually, the solution is pretty simple:

do '(if (abs(t-5σ)<σ),1,0)' for a rectangular pulse in [4σ,6σ]. This σ needs to be hard coded to a numerical value or use the unfriendly function num2string(). As a proof of concept, please find the code that generates 2 well separated rectangular pulses.
Attachments
dipv5_4long2rect.m
Code example