The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Matrixsheet setting a fixed value to row/column

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
AKazak Posted - 11/23/2025 : 02:27:15 AM
OriginPro 2026 (64-bit) Beta6 10.3.0.156
Windows 10.0.19045.6575 Pro 22H2

Greetings!

I have a matrix book Mbook with a single matrix sheet MSheet with a single matrix object Mat(1).

Can you share a LT snippet to set a user-defined fixed value to the selected (specified by index) row/column of Mat(1), please?

I appreciate getting your response shortly.

---
Andrey
9   L A T E S T    R E P L I E S    (Newest First)
minimax Posted - 11/26/2025 : 04:32:24 AM
Hi Andrey,

I am afraid currently there is no LT access on whole row/col (subset) of matrix.

You may take a look at Origin C interface, like
https://www.originlab.com/doc/OriginC/ref/matrixbase-GetAsVector
https://www.originlab.com/doc/OriginC/ref/matrixbase-SetByVector

Or if you are open to Python, you may take some try too, like below.


import originpro as op
import numpy as np
mb=op.find_book('m')
ms=mb[0]   #assume it is a 5*5 dimension obj
arr = ms.to_np2d(0)
row1 = arr[0]   #1st row
col3 = arr[:,2] #3rd col
row1=row1+100
col3=col3-200
arr[0]=row1
arr[:,2]=col3
ms2=op.new_sheet('m')
ms2.shape=5,5   #set same size as source mat object
ms2.from_np2d(arr)
AKazak Posted - 11/25/2025 : 08:58:06 AM
quote:
Originally posted by minimax

Hi Andrey,

following script with cell() function should also work.

And it is recommended to define range to access.


range rmat1=[Mbook1]Msheet2!2;
rmat1!cell(2,3)=4;





Got it.
How do I refer to individual rows and columns of a matrix object?

---
Andrey
AKazak Posted - 11/25/2025 : 08:47:01 AM
quote:
Originally posted by aplotnikov

quote:
Originally posted by AKazak
https://www.originlab.com/pdfs/5_matrix.pdf does not mention matrix object and implicitly assumes a matrix with a single matrix object in it.

It is not true. You can use Mat(n)-notation to access n-th matrix object:
[<Matrix name>]<MSheet>!Mat(<n>)[N*(i-1) + j] = ...

For instance:
[MBook1]1!Mat(2)[66]=66



Well noted.
Thank you!

---
Andrey
minimax Posted - 11/25/2025 : 05:25:32 AM
Hi Andrey,

following script with cell() function should also work.

And it is recommended to define range to access.


range rmat1=[Mbook1]Msheet2!2;
rmat1!cell(2,3)=4;

aplotnikov Posted - 11/24/2025 : 8:09:12 PM
quote:
Originally posted by AKazak
https://www.originlab.com/pdfs/5_matrix.pdf does not mention matrix object and implicitly assumes a matrix with a single matrix object in it.

It is not true. You can use Mat(n)-notation to access n-th matrix object:
[<Matrix name>]<MSheet>!Mat(<n>)[N*(i-1) + j] = ...

For instance:
[MBook1]1!Mat(2)[66]=66

AKazak Posted - 11/24/2025 : 09:20:07 AM
quote:
Originally posted by aplotnikov

https://www.originlab.com/pdfs/5_matrix.pdf

Note 2: You can reference a single cell

MatrixName[N*(i-1)+j]
where:
N = the number of columns in the matrix
i = the row number in the matrix.
j = the column number in the matrix.



https://www.originlab.com/pdfs/5_matrix.pdf does not mention matrix object and implicitly assumes a matrix with a single matrix object in it.

What is the general way to access/modify values in a certain matrix object?

---
Andrey
AKazak Posted - 11/24/2025 : 09:09:50 AM
quote:
Originally posted by aplotnikov

https://www.originlab.com/pdfs/5_matrix.pdf

Note 2: You can reference a single cell

MatrixName[N*(i-1)+j]
where:
N = the number of columns in the matrix
i = the row number in the matrix.
j = the column number in the matrix.



Thank you for sharing this.
I will test this approach soon.

---
Andrey
aplotnikov Posted - 11/24/2025 : 03:35:29 AM
https://www.originlab.com/pdfs/5_matrix.pdf

Note 2: You can reference a single cell

MatrixName[N*(i-1)+j]
where:
N = the number of columns in the matrix
i = the row number in the matrix.
j = the column number in the matrix.
AKazak Posted - 11/23/2025 : 02:30:00 AM
I could not find the answer from the following resources:
https://www.originlab.com/doc/LabTalk/ref/Wks-Col-obj
https://www.originlab.com/doc/LabTalk/guide/Matrix-Basic-Operation
https://www.originlab.com/doc/en/X-Function/ref/msetvalue
https://www.originlab.com/doc/en/LabTalk/ref/Matrix-cmd
https://www.originlab.com/doc/LabTalk/guide/Matrix-Object-Data-Manipulation
https://www.originlab.com/doc/en/LabTalk/guide/Worksheet-Column-Data-Manipulation

---
Andrey

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000