Rank: Advanced Member Groups: Registered
Joined: 10/02/2019(UTC) Posts: 56 Location: Colorado
|
Is it possible to assign specific values to specific elements and take the absolute value of other specific elements of a large vector with say 400 elements? I have tried for loops and if structure to no avail. I assume I just still don't understand the syntax in SMath.
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 28/08/2014(UTC) Posts: 1,368 Was thanked: 829 time(s) in 525 post(s)
|
Hi. Something like this? vector.sm (7kb) downloaded 15 time(s).Best regards. Alvaro.
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 10/02/2019(UTC) Posts: 56 Location: Colorado
|
Thanks for your help. What if I don’t know the positions that need changing ahead of time? In my vector of about 400 elements, some values are negative. I would like to change only those values to about 10^-10 or take their absolute value and leave all the other elements of the vector unchanged because I plan to plot the vector on a log-log plot.
This is quite easy to do in Mathcad, but it seems SMath doesn’t have the same capability. When I try to test on a value of an element using SMath’s if statement to see if that vector element needs changing I get syntax errors in SMath.
I was hoping to use something like this, but it doesn’t work.
k := [1...length(I)]
A[k := if I[k<= 0 10^-10 else I[k
Where I is the vector of about 400 elements
Forgive the [ since the forum doesn’t allow subcripts or less than or equal. I am on my iPad now and the forum also does not allow uploading jpg from my photos.
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 10/02/2019(UTC) Posts: 56 Location: Colorado
|
Here is a better image.
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 28/08/2014(UTC) Posts: 1,368 Was thanked: 829 time(s) in 525 post(s)
|
This? vector.sm (5kb) downloaded 13 time(s).Best regards. Alvaro.
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 10/02/2019(UTC) Posts: 56 Location: Colorado
|
Thanks much. I thought I tried that in using a program line, but I guess I had some typo. Thanks again!
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 10/02/2019(UTC) Posts: 56 Location: Colorado
|
I tried to click on thank for you, but I got an error. Perhaps the forum doesn’t like iPads.
Again I really appreciate your help.
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 28/08/2014(UTC) Posts: 1,368 Was thanked: 829 time(s) in 525 post(s)
|
Hi. The method in your picture, using range vectors, fails because 'if' have an special evaluation method, For instance, the true or false parts are evaluated only if the condition results in true or false, respectively. This method is a workaround, but isn't very efficient. vector.sm (8kb) downloaded 16 time(s).Best regards. Alvaro.
|
1 user thanked Razonar for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 10/02/2019(UTC) Posts: 56 Location: Colorado
|
Interesting; thanks for that also.
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 981 time(s) in 809 post(s)
|
Originally Posted by: RegCurry Is it possible to assign specific values to specific elements The attached is not exactly what you are looking for, suggestive of Bolean Find-Replace in matrix. Your 400 long vector is not easy to inspect, you can Pack in matrix, probably Find-Replace in that more visible Packed matrix, then Unwrap the processed matrix back in vector. IMHO, it does not make much sense to |absolute| a vector. Does it mean the vector-creator is under-designed ? Matrices-Vectors ... what you do in Mathcad, Smath does. Easy to select-collect position of elements in vector, then replace those selected elements by new values. You seem to have several demands to the "Cat in the hat Fairy", Maybe she has all and +++ Cheers ... Jean Utilities Matrix Find_Replace.sm (22kb) downloaded 15 time(s).
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 981 time(s) in 809 post(s)
|
Originally Posted by: RegCurry Is it possible to assign specific values to specific elements ... more matrix utilities Utilities Matrix Treasury_1.sm (395kb) downloaded 23 time(s).
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 15/04/2012(UTC) Posts: 1,990 Was thanked: 1128 time(s) in 724 post(s)
|
|
|
3 users thanked mkraska for this useful post.
|
on 08/03/2019(UTC), on 08/03/2019(UTC), on 09/03/2019(UTC)
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 981 time(s) in 809 post(s)
|
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 981 time(s) in 809 post(s)
|
Originally Posted by: RegCurry In my vector of about 400 elements, some values are negative.I would like to change only those values to about 10^-10 or take their absolute value and leave all the other elements of the vector unchanged because I plan to plot the vector on a log-log plot. Reg: that's what we need the 400 long vector. Supplementary instructions/abstract guidance too.
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.