Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X
Hi there ,
I have a nested variable called x =[k v m] as shown in the screen shot
I need to divide x by n
which means that each row in x will be divided by n >>> so k/n , v/n, and m/n>>>>
the result should look like x
Thanks in advance
Solved! Go to Solution.
In the sheet you posted it was variable "x" which had that nested structure.
Now it seems to be q.c. So you would have to write q.c instead of x in both variants.
The point is that the variable you use at the left hand side of the assignment must already have the nested data structure.
You could also turn the calculation into a function, but this probably would not make much sense as you would only use it once.
But here the name of the formal function arguments must not have something to do with the names of the actual arguments you use.
Nonetheless you should be aware that all these routines are not generic utility routines but only work with the very specific data structure you had provided.
So your data, your vector x basically consists of nine 5x1 vectors and you want the elements of each of this nine vectors by the elements of the 5x1 vector n? Is this correct.
Bu the nine 5x1 vectors are arranged in a double nested way in x.
I wonder if this nested data structure really is mandatory for your application.
If its is I would suggest using a small program with nested if-loops instead of fiddling around with range variables.
You should also be aware that 100% = 1, so multiplying by 100% has no effect at all.
But you always can display numeric results formatted in percent if its that what you tried to do
BTW, your attempt with vectorization failed because x[i.n and n are not vectors of the same structure. n is a 5x1 vector consisting of scalars, but x[i.n is a 3x1 vector consisting of 5x1 vectors of scalars.
Basically vectorization cycles through the elements of the vectors (just the top level) and applies the calculation to each element. So you can replace vectorization by an explicit loop. Here a version where the vectorization used above is replaced by an additional for-loop (k):
Word of caution: Prime would throw an error if you replace the x in x[i[j[k on the left hand side of the assignment by any other variable like R (for Result/Return value) because it can't generate that multiple nested structure in one go.
If you feel uncomfortable with x also use as return value variable you would have to do it that way
Hi Werner,
I hope you are doing well.
1) I wonder if this nested data structure really is mandatory for your application>>> Yes it has to be like this ...
this is the orginal sheet ...I think your caution happens ?
Prime would throw an error if you replace the x in x[i[j[k on the left hand side of the assignment by any other variable like R (for Result/Return value) because it can't generate that multiple nested structure in one go.
In the sheet you posted it was variable "x" which had that nested structure.
Now it seems to be q.c. So you would have to write q.c instead of x in both variants.
The point is that the variable you use at the left hand side of the assignment must already have the nested data structure.
You could also turn the calculation into a function, but this probably would not make much sense as you would only use it once.
But here the name of the formal function arguments must not have something to do with the names of the actual arguments you use.
Nonetheless you should be aware that all these routines are not generic utility routines but only work with the very specific data structure you had provided.
That works now>>>>>>>>.. Thank youuuuuuuuuuuuuuuuuuuuuuu