Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
Hi there,
Any ideas why this is wrong? I made f as function of M in order to define it
Regards
Yusra
Solved! Go to Solution.
You've still got the "=" sign at the end of the function definition, Yusra. You need to go to the very end of the function definition (Fn-right-arrow), then press Backspace twice. That should remove the equal sign.
Stuart
Try getting rid of the following equals sign in the function definition
still the same
You've still got the "=" sign at the end of the function definition, Yusra. You need to go to the very end of the function definition (Fn-right-arrow), then press Backspace twice. That should remove the equal sign.
Stuart
So I can't put (=) in the function . Thank you for that I didn't know
Now I have this another error that I always get . Can you explain to me how to tackle it
@YA_10963798 wrote:
So I can't put (=) in the function . Thank you for that I didn't know
No worries.
@YA_10963798 wrote:
Now I have this another error that I always get . Can you explain to me how to tackle it
Without the worksheet, I'd be flying blind, but my first airport of call would be to check whether dzontgr is the same length as g`ontg.
Stuart
@YA_10963798 wrote:
So I can't put (=) in the function .
Not after a function DEFINITION.
An = means a numeric evaluation. Which numeric result would you expect here:
Prime can't know which value to use for "x". Even if a variable "x" is defined in front it won't work, because the "x" used in the right hand side of the function definition is NOT the "x" you may have defined in front but rather is the "x" used on the left hand side of the definition (formal function argument).
So when you DEFINE a function you can't evaluate this definition numerically. But after the definition, when you CALL the function providing a specific value for the formal argument you evaluate this function call numerically.
Actually you CAN evaluate a function definition using symbolic evaluation.
But this will not always work OK. If the function definition contains a boolean expression using the function argument(s) it can't decide its truth value without knowing specific values and so will refuse to evaluate symbolically
Now I have this another error that I always get . Can you explain to me how to tackle it
I also suspect that vector dzontgr contains not more elements than vector σ'ontg.
So when in your loop "i" reaches the index of the last value of σ'ontg, there is no element with index i+1 in vector dzontgr.
Probably the same applies to vector γ'ontg.
If all the mentioned vectors are of the same length the error should go away if you use for i ∈ ORIGIN..last(σ'ontg)-1
The resulting vector returned by your function will have one element less than the vectors used. You have to decide if that's what you need.
Thank you Werner for the thorough explanation.
when I use (
won't that exclude the last value?
When I did what you said .. I got this value with unit in the second raw ?
f2 must be unitless because the units should cancel each other
Regards
Yusra
OK, now we see that all the vectors involved consist of two elements only
The reason that the result of your function f2 is still a 2x1 vector and not just a single value inside a 1x1 matrix/vector is the first line in your function definition, R <- M.
So when you use last(..)-1 the calculation is only done for the first element and the second(last) element of R is not calculated at all but rather is the second(last) element of M unchanged - that's the reason you see unit Pa.
If you delete this first program line the result will be a unitless value, but in a 1x1 vector - as I wrote before, one element less than the vectors involved.
The the main problem still is: The calculation von R.i uses the elements with index i from some of the vectors, but also the element with index i+1 from some other vectors.
So when you tried to calculate R.2 this calculaton would use the elements with in index 2 of some vectors but also the elements with index 3 of some other vectors. And these vectors only have 2 elements so there is no element with index 3, hence the error you got.
You have to know how to deal with that problem, what exactly you are trying to calculate and how to deal with the last value in T in case you expect the outcome of the function f2 to be a 2x1 vector as well.
Yes you are right . I will fix that
Thanks
How can I exclude the first value not the last one ?
I tried to put the first one as 0 so now I have 3 values in each element .. I need it to calculate the second and the third (the last values )
Which first value?
Can you post a sheet which only includes this function, the needed vectors and show manually what you expect as the result?
generally if you want to delete the first value in a vector you could use the 'submatrix' function (assuming ORIGIN=1): v:=submatrix(v, 2, last(v), 1, 1)
But I am not sure if that is what you are trying to achieve.
> I tried to put the first one as 0 so now I have 3 values in each element .. I need it to calculate the second and the third (the last values )
?? third value?? The calculation of the third value would use the non-existing fourth value of some vectors and you would end up with the same problem as before. But maybe I misunderstood something.
BTW, as far as I can tell there is no need to divide by MPa as the units would cancel anyway also without doing so.
the matrixes I have is for 2 layers , so 2 rows and I'm trying to calculate f2 for the two rows so I should have as a result two values for f2 ..
the problem I have is the f2 for the first value should be calculated from previous layer which is not there so I added this layer as zero values for all the vectors in this function. now I have three layers .. I want to get f2 for the second and the third layer assuming that the first one is zero
when I use ( last -1) it exclude the last layer which I need . I want it to exclude the first one which is zero and still be able to use the same loop (for)
I attached the sheet
thanks
You have to see if the modifications I made yield the result which you expect.
I changed the units of the vector gamma from Pa to Pa/m
I left your loop running from ORIGIN+1 up to last sigma'), but I changed all indices by subtracting 1. i->i-1 and i+1->i
I also changed the running index in your sum from i to k as i is already used for the upper limit of the sum.
Apart from that, I only removed unnecessary parentheses and the vectorization.
You have to check if the results are the correct values you expected.
Ok thanks
