How to use SetCustomExcite for a shifted signal?

How to use openEMS. Discussion on examples, tutorials etc

Moderator: thorsten

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

How to use SetCustomExcite for a shifted signal?

Post by jjmaloss » Wed 17 Mar 2021, 05:54

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?

Post by jjmaloss » Thu 18 Mar 2021, 22:16

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
(5.54 KiB) Downloaded 78 times

Post Reply