Skip to main content
5-Regular Member
February 5, 2024
Solved

Adding a scalar to every other Column in a Matrix

  • February 5, 2024
  • 2 replies
  • 1270 views

Using: MathCAD Prime 9.0

Hello,

I am trying to add a scalar value to every other column in a large matrix (each element in an even column). I included a screenshot below of a small scale example of the input matrix M, scalar value to add, and the desired output. I thought this might be able to be accomplished using a for loop of some kind looping through the elements and only adding the scalar to the even columns, but I wasn't able to figure out how to do this.

Screenshot 2024-02-05 180237.png

The real application is I have a large matrix of time and current values with every other column being the time columns, and want to add a scalar value to shift the time values.

Any help would be greatly appreciated!

Best answer by Werner_E

I would suggest using a small user-written utility function (which also should be ORIGIN-aware for maximal portability):

Werner_E_0-1707189791845.png

Prime 9 sheet attached

 

2 replies

21-Topaz II
February 5, 2024
Werner_E25-Diamond IAnswer
25-Diamond I
February 6, 2024

I would suggest using a small user-written utility function (which also should be ORIGIN-aware for maximal portability):

Werner_E_0-1707189791845.png

Prime 9 sheet attached