Jump to content
OMRON Forums

How to assign values for all elements of matrix variable


tanakakai

Recommended Posts

I would like to create some matrix variables to hold certain parameters for my PMAC program.

 

As I understand it, the format for defining a matrix is:

global mymatrix(n)

Where n is the number of elements in the matrix.

 

I can't find anything in the documentation that explains how I can set the values for all elements in the variable. Is there some way I can do something like this:

 

global mymatrix(5);
mymatrix = (1,2,3,4,5)

Such that mymatrix(0)=1, mymatrix(1)=2, etc?

 

edit:

Also wondering if there is a function that finds (or defines) the length of the vector so I can be sure my indexing variable does not exceed the matrix length. Something like:

mymatrix.index

 

There has to be a way that the software knows how many P variables to reserve. Is the index variable generic and overwritten each time a new matrix is created? If so I suppose I should define matrix length via another variable like:

global matrixlength = 5;
global mymatrix(matrixlength);

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I am just passing along this information, so hopefully this answers your question:

 

#define matrixsize 10

global matrix(matrixsize);

matrix(0)=1,2,3,4,5,6,7,8,9,10

 

The #define is available to use in your programs.

 

Thanks Gregs! Adding the '(0)' to the end in order to assign values to the matrix was not intuitive. I think this will help me move forward with my code, I appreciate it!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

×
×
  • Create New...