Author Topic: How do I slice a vector in a Qucs simulation using an equation?  (Read 998 times)

0 Members and 1 Guest are viewing this topic.

Offline niconiconiTopic starter

  • Frequent Contributor
  • **
  • Posts: 350
  • Country: cn
How do I slice a vector in a Qucs simulation using an equation?
« on: November 07, 2022, 03:52:45 am »
Any Qucs expert here? I'm trying to calculate some circuit parameters in Qucs using user-defined equations from the simulation results. The simulation is a 1001-point transient simulation, the output node is labelled as "out". After the simulation completes, the output voltage versus time is accessible as a vector out.Vt, and one can access the n-th element using the syntax out.Vt[n] in a user-defined equation. For example, out.Vt[500] is the 500th data point.

Now I need to slice this vector, for example, to obtain the first 500 data points. But I don't know the correct syntax for this task. I've already read the documentation, including Short Description of Mathematical Functions, and Measurement Expressions Reference Manual. Unfortunately, none of these documents contain any helpful example.

I've already tried out.Vt[1:500] and out.Vt[1,500]. But I got either an "Invalid" or "Wrong Dependency" error. What is the correct syntax for slicing a vector in Qucs?

I've already posted this question on Stack Exchange and the Qucs mailing list, but so far didn't get any response. Unfortunately Qucs is a dying breed these days due to lack of development and maintenance, despite the fact that it's still a fairly powerful free and open source circuit simulator.
 

Offline mag_therm

  • Frequent Contributor
  • **
  • Posts: 654
  • Country: us
Re: How do I slice a vector in a Qucs simulation using an equation?
« Reply #1 on: November 07, 2022, 06:27:22 am »
The following in an equation block will give vectors for plotting within a span, the values outside the span are set to 0

My_span1=time<1.33e-7?time:0
My_span2=time>1.33e-7?time:0
Out1=My_span1?Out.Vt:0
Out2=My_span2?Out.Vt:0
Note that the case else :0 must be included.

If you need to create new truncated vectors, there may be a similar way, but I have not tried that.
maybe functions eye() and linspace()
If you can work out how to do that within qucs, I would like to see your method.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf