01-21-2025 11:42 AM
I only need to get the output to show an off diagonal elements like this,
formula to get off diagonal:
nbr=3
Here is what I did.
a 3 by 3 output by using the 1d array and zeros (3by3)
To be fair i am not sure what i was doing here because i was just trying out everything and could not understand. Hopefully, someone can help me. I have attached the file.
Solved! Go to Solution.
01-21-2025 11:51 AM - edited 01-21-2025 12:05 PM
@Rusyaidi_arif_cute wrote:
I only need to get the output to show an off diagonal elements like this,
formula to get off diagonal:
nbr=3
I don't understand your formula, because 2D arrays have two indices, not just one (k).
You have two array constants, which one would you like to process?
Your 2D arrays are not square, so the concept of "diagonal" is poorly defined.
Given the default input, what would be the correct result?
Why would you need to spin that loop millions of times per second doing the same thing over and over?
Are you aware that index array is resizable? Compare these two fragments:
01-21-2025 12:18 PM
For starters, I did know it was resizable but didn’t know the function for it. Im surprised it could get much more simpler and less blocks than before!
The while loop all over it was just me trying to understand what it does to everything. Forgot to remove it.
The constant k in that formula refers to a number in the specified row,column vector for example Y(1,2) would represent an element of row 1 and column 1
Y=[Y(1,1) Y(1,2) Y(1,3)
Y(2,1) Y(2,2) Y(2,3)
Y(3,1) Y(3,2) Y(3,3)]
I want to make the diagonal part to be 0.
I cant seem to understand how to.
1d Array is my input Y(k)
whereas Y(zeros) are just Y (3by3) with all zeros in it.
sorry for bad english.
01-21-2025 12:30 PM
01-21-2025 07:11 PM
Yes thats how i want to create thank you so much! I will try to do it with my input.
01-21-2025 07:35 PM
That's one of the objective done, another thing is how would I do it if for example in your case,
(4 by 4) array were added with a 1d array
1d array:- [1
2
3
4]
To make it simpler my formula takes an element from each row of 1d array for example the first row =1, and then
it will add with an element inside (4by4) array, in row 1, col 2 ,vice versa so it would be Y(1,2) & Y(2,1) of the array. The second row of 1d array=2, will add onto another element of Y(2,3)& Y(3,2) and so on.
01-22-2025 01:23 AM
Hi Rusyaidi,
@Rusyaidi_arif_cute wrote:
another thing is how would I do it if for example in your case,
(4 by 4) array were added with a 1d array
1d array:- [1
2
3
4]
To make it simpler my formula takes an element from each row of 1d array for example the first row =1, and then
it will add with an element inside (4by4) array, in row 1, col 2 ,vice versa so it would be Y(1,2) & Y(2,1) of the array. The second row of 1d array=2, will add onto another element of Y(2,3)& Y(3,2) and so on.
Just implement your calculations, using a loop with a shift register and some array functions (like IndexArray and ReplaceArraysubset).
(Once you have done so you may learn about the InplaceElement structure and how to use it with array data…)
01-22-2025 02:28 AM - edited 01-22-2025 10:13 AM
@Rusyaidi_arif_cute wrote:
To make it simpler my formula takes an element from each row of 1d array for example the first row =1, and then
it will add with an element inside (4by4) array, in row 1, col 2 ,vice versa so it would be Y(1,2) & Y(2,1) of the array. The second row of 1d array=2, will add onto another element of Y(2,3)& Y(3,2) and so on.
That's not really "simpler", just more confusing. How big is the 1D array and how does its size depend on the size of the 2D array? What is the meaning of "vice versa" and "and so on". Very ambiguous! Does each element of the 1D array go into multiple places?
You also need to be very careful with terminology. For example the word "add" mathematically means to add the new element to the existing element at the desired location. Colloquially, it could also mean to "replace" the current element with the new value.
In simper terms, why not just describe the desired result.
For example if the 2D array is
A B C D
E F G H
I J K L
M N O P
and the 1D array is:
Q R S T
How should the result look like?
01-22-2025 03:23 AM
I see I need to be careful with the terminologies as well but sorry for the confusion. I really meant add as in mathematical addition.
The size of 1D array depends on maximum no. of input rows
The Maximum size of 2D array depends on maximum element inside "nr" or "nl" of my original code.
The results will look like this
where A, F, K ,P = 0.
D H M N = any number. In this case is 0.
A B+Q C+R D
E+Q F G+S H
I+R J+S K L+T
M N O+T P
01-22-2025 11:03 AM
So, what are the rules??
:
Do you have a link to a website that describes the math and purpose behind this exercise?