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

Shift values in matrix

PZ_9812318
2-Explorer

Shift values in matrix

Hey, I liked to know how to shift the values at matrix by a certain value like this.

Výstřižek.PNG
I have script in MathCad and matrix with hundreds values, and I need it to work automaticly. Thanks for help.

9 REPLIES 9
LucMeekes
23-Emerald III
(To:PZ_9812318)

LucMeekes_0-1617784735196.png

Success!
Luc

 

Thanks a lot, it works, you are very kind.

Werner_E
25-Diamond I
(To:PZ_9812318)

Here are my 2 cents

In contrary to Luc's "Mrot", my "Mshift" uses programming and therefore does not work in the limited Prime Express version. Also notice that Mrot and Mshift rotate/shift in different directions.

Doubling the data by stacking the matrix on top of itself is bold and may be considered inefficient, but this should not be a problem with matrices of just a few hundreds of rows 😉

Werner_E_1-1617795549729.png

 

You may also use the same function to shift both rows and columns:

Werner_E_1-1617796107403.png

 

P6 worksheet attached

It can be with built in functions:

MSheykman_0-1617894530035.png

 

Or just by mangling with indices as follows:

MSheykman_0-1617894793872.png

 

Or a pure math solution:

MSheykman_0-1618121562379.png

 

LucMeekes
23-Emerald III
(To:MSheykman)

Yes, there are multiple roads that lead to Rome.

I guess that for shifting/rotating the rows of a vector or matrix, first filling an nxn matrix is a bit overdone. Besides, this method doesn't work (as intended) for shifting/rotating rows of matrices....

 

Luc

Werner_E
25-Diamond I
(To:LucMeekes)


@LucMeekes wrote:

Yes, there are multiple roads that lead to Rome.

I guess that for shifting/rotating the rows of a vector or matrix, first filling an nxn matrix is a bit overdone. Besides, this method doesn't work (as intended) for shifting/rotating rows of matrices....

 

Luc


I agree that the way the idea was presented isn't very practical for actual use.

But the principle can be turned into a convenient utility function which works on the rows of matrices, too 😉

Werner_E_0-1618151818142.png

Because the "matrix" function ignores the setting of ORIGIN, the function should also be ORIGIN-aware.

 

On the other hand ... it seems that @PZ_9812318  is no longer interested in his question. 😞

 

It is possible to generate the rotation matrix if you do not feel like filling it in with 0 and 1 manually.

MSheykman_0-1618220086216.png

If you need to populate a sparse matrix - you only need to set the values that are not equal to 0, others will become zero automatically. The dimension is defined by the largest row and column indices that you used while assigning values to specific elements.

j in the example contains an expression of i, that define how elements will be reordered.

Announcements

Top Tags