Hello i want to multiply 2 arrays for one of my projects which i am currently working on.
Here is the code which i am trying to run:
Program POU
VAR
a: array [1..5,1..2] of real:= [1,2,3,4,5,6,7,8,9,1];
b: array [1..2,1..5] of real:= [1,2,3,4,5,6,7,8,9,1];
c: array [1..5,1..5] of real;
END_VAR
How can this be done? It would be great if someone can help me
Last edit: nehaltrivedi 2022-08-22
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello i want to multiply 2 arrays for one of my projects which i am currently working on.
Here is the code which i am trying to run:
Program POU
VAR
a: array [1..5,1..2] of real:= [1,2,3,4,5,6,7,8,9,1];
b: array [1..2,1..5] of real:= [1,2,3,4,5,6,7,8,9,1];
c: array [1..5,1..5] of real;
END_VAR
How can this be done? It would be great if someone can help me
Last edit: nehaltrivedi 2022-08-22
more posts ...
Try the Matrix Library, available by searching Matrix Library in CODESYS Installer > Change > Browse
But i checked and it seems isn't this library a paid one?
And can't we multiply without matrix library?
I don't know of another way. I guess you could find an algorithm and convert it manually to IEC 61131-3.
Since you already got the values in arrays cant you just loop through them?
I am not able to identify what you are trying to tell, would be great if you can explain.
Maybe i do not understand how you want them multiplied?
I was thinking of something like this:
Last edit: ojz0r 2022-08-18
I wanted to multiply the matrix a and matrix b which yields the result c = a*b.
But C would be a new array, or do you want the array elements of C summed up?
Yes sorry C would be a new array. I want something like this c=a*b; I have edited the original problem statement.
Okay so here is the loop(s) needed for the calculation:
Do i need to initialise C[k,i] to 0's?
Something like this:
c: array [1..5,1..5] of real := [25(0)];
Initializing to zero is always a good idea to be sure variables are empty before a calculation.