cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Summing up Current Data columns in a Matrix based on associated Time Values

MM_10946130
3-Visitor

Summing up Current Data columns in a Matrix based on associated Time Values

Using Prime 9.0

Hello,

I have a large matrix of time and current data for 6 different channels. The even columns (0,2,4,6,8,10) contain the time data for the odd current data columns to the right (1,3,5,7,9,11) - Excel image shown below for visual clarity.
I am trying to sum up the current data of the 6 channels into a 2 column matrix (time, current) adding the currents at the appropriate times. The time data is in microseconds with time steps of ~.006-.007 μs and the channels time data overlap with start times shifted by 7.5 μs. For example, Channel 0's time data spans from 7.5 μs to 41 μs, Channel 1's time data spans from 15 μs to 48.5 μs, and so on. I wrote the matrix data to an excel file and attached. 

Excel Image:

MM_10946130_1-1707764378704.png

MathCAD matrix:

MM_10946130_0-1707763841838.png

It's kind of hard to explain verbally, but basically the channels have time and current data that overlap, and I want to add the currents of the overlapping times accordingly. 

I have a user-defined function that simply adds up the odd current data columns together, but doesn't take into account the time data at all...

MM_10946130_0-1707766116390.png

Let me know if further clarification is needed, and I appreciate any help with this!

 

1 ACCEPTED SOLUTION

Accepted Solutions

So you simply want to add up the six sine-looking signals?

Doing it with the values in the table might be problematic.

 

channel 0 might have values at time stamp 80 ms and 82 ms but channel 1 might have timestamps 79 ms, 81 ms and 83 ms.

So I guess you will want to interpolate?

 

My suggestion would be to create interpolating functions (linear interpolation with "linterp" might be all thats needed), limit the function to the appropriate time range for each channel and then create the sum of all six functions.

 

Would this approach do the job?

Werner_E_0-1707783599969.png

Of course you now could sample the sum signal using time steps of your choice if you really need a vector of values.

View solution in original post

9 REPLIES 9

Its not clear to me what exactly you would like to add up and how you would like to involve the time stamps - especially its unclear what you mean by overlapping times.

 

Are you trying to implement some kind of numeric integration of the current over time, the result being charge values (ampere*seconds or Coulomb)?

 

Maybe you give an example of the result for one of the channels along with an explanation how you would arrive at that result with manual calculation.

And don't forget to attach your Prime worksheet.

 

Here is what I was talking about. Not sure if its what you are looking for, though

Werner_E_0-1707776391005.png

 

Prime 9 file attached

 

Hi, it might be easier to understand with a simple small scale example. I attached the Prime sheet. In this case, the output matrix contains the whole time range from 0 to 1.5 seconds, and the current data is summed together from all the channels - constant value of 1 A for simplicity. When I said "overlapping" before, I meant the portion of the channels time data of the same range. For example, Channel 0 is from 0 to .9 s, and Channel 1 is from .2 to 1.1 s, so .2 to .9 s are "overlapping" time values and the current data at each matching time point should be added up. In this example, at the time of 1.0 seconds, the output matrix has a value of 3 Amps since Ch1, Ch2, and Ch3 all contain the 1.0  time value which have values of 1 A each.
In the original application, the time steps between the channels might not be exactly uniform between the different channels. Likely within .002 μs, if not the exact values.
Hope that makes sense.

MM_10946130_1-1707777229404.png

 

 

 

So you simply want to add up the six sine-looking signals?

Doing it with the values in the table might be problematic.

 

channel 0 might have values at time stamp 80 ms and 82 ms but channel 1 might have timestamps 79 ms, 81 ms and 83 ms.

So I guess you will want to interpolate?

 

My suggestion would be to create interpolating functions (linear interpolation with "linterp" might be all thats needed), limit the function to the appropriate time range for each channel and then create the sum of all six functions.

 

Would this approach do the job?

Werner_E_0-1707783599969.png

Of course you now could sample the sum signal using time steps of your choice if you really need a vector of values.

Yes, interpolation sounds like a good idea. I think linterp() should work. Would you be able to provide a solution using this approach? I'm not the most familiar with MathCAD yet, so it'd likely take me some time to figure out how to do it myself.


@MM_10946130 wrote:

Yes, interpolation sounds like a good idea. I think linterp() should work. Would you be able to provide a solution using this approach? I'm not the most familiar with MathCAD yet, so it'd likely take me some time to figure out how to do it myself.


I already edited my previous answer to show my attempt quite a while ago. Didn't it show up?

oh, yes. I was looking at the page, and there wasn't anything there. But it's there after refreshing. I see it now. Thanks! I do still need a vector of values, as I will be using the summed current matrix for further calculations.


@MM_10946130 wrote:

oh, yes. I was looking at the page, and there wasn't anything there. But it's there after refreshing. I see it now. Thanks! I do still need a vector of values, as I will be using the summed current matrix for further calculations.


So you may sample the sum signal in any time range with any step width you need. "currSum" can be used as any function and can be evaluated at any time value you like.
In case you need help creating the vectors, see at the end of the attached file.

This looks great! Thanks so much for your help and patience in interpreting my possibly unclear original description of the problem... I love how well-organized your work is, and the included tips mentioned! I'm just starting to use MathCAD at work, so your experienced replies are much appreciated 🙂

Top Tags