Group Abstract Group Abstract

Message Boards Message Boards

0
|
2.2K Views
|
4 Replies
|
1 Total Like
View groups...
Share
Share this post:

How can I plot a system's response depending on certain condition

Posted 1 year ago
4 Replies

Sorry, I don't know the meaning of your plots, but here a reworking that runs:

Clear[TF1, inwave, coupling, v1];
PulseWave[duty_, t_, period_, phase_] := 
  UnitBox[Mod[(t/period) + phase, 1]/(2 duty)];
TF1 = TransferFunctionModel[{{(697052. + 25694.6 s)/(700128. + 
        25835.5 s + 1. s^2)}}, s, SamplingPeriod -> None, 
   SystemsModelLabels -> None];
inwave[t_] = 
  OutputResponse[TF1, 
    40*10^-3 PulseWave[0.25, t, 10^-3, 0], {t, 0, 4 10^-3}][[1]];
Plot[inwave[t], {t, 0, 4 10^-3}, PlotLegends -> {"inwave"}]
coupling[t_] = OutputResponse[TF1, inwave[t], {t, 0, 4 10^-3}][[1]];
Plot[{coupling[t], inwave[t]}, {t, 0, 4 10^-3}, PlotRange -> All, 
 GridLines -> {{}, {.015}}, PlotLegends -> {"coupling", "inwave"}]
v1[t_] = If[coupling[t] >= 0.02, inwave[t], 0];
Plot[v1[t], {t, 0, 4 10^-3}, PlotRange -> {-.01, .045}, 
 GridLines -> {{}, {.015}}, PlotLegends -> {"v1"}]
POSTED BY: Gianluca Gorni

Thank you so very much! It works perfectly. I am trying to model a biological system of action potential propagation and this is related to that work. Thanks a lot for your kind help.

Dear Gianluca, Thank you so much. As such it worked in a reverse way, i.e., I am getting the response only when I set coupling <= 0.015, although I can see that coupling for certain times is >=0.015. Not sure why this happens. For coupling >=0.015 it always gives flat line at 0. Any help will be much appreciated. Here is the code again with your suggested modification.

PulseWave[duty_, t_, period_, phase_] := 
  UnitBox[Mod[(t/period) + phase, 1]/(2 duty)];
TF1 = TransferFunctionModel[
   Unevaluated[{{(697052. + 25694.6 s)/(
     700128. + 25835.5 s + 1. s^2)}}], s, SamplingPeriod ->None, 
   SystemsModelLabels -> None];
inwave = 
  OutputResponse[TF1, 
   40*10^-3 PulseWave[0.25, t, 10^-3, 0], {t, 0, 4 10^-3}];
Plot[inwave, {t, 0, 4 10^-3}];
coupling = OutputResponse[TF1, inwave, {t, 0, 4 10^-3}];
Plot[coupling, {t, 0, 4 10^-3}, PlotRange -> All]
v1 = If[coupling[[1]][[1]] >= 0.015, inwave, 0];
Plot[v1, {t, 0, 4 10^-3}, PlotRange -> All]

Your coupling is a list, you cannot compare it to a number. Try this:

v1 = If[coupling[[1]] >= 0.015, inwave, 0]
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard