1 Pages (4 items)
Trouble with rows() - Trouble with rows(X) when X is scalar. - Messages
#1 Posted: 10/26/2015 10:47:35 AM
Question:
I'm using solve() to get results and saving those under "M", then I'm defining N:=rows(M), and that is point where trouble starts - solve() can give results
in form of either vector or scalar, depending on the function used in it and if result "M" is scalar rows(M) fails.
So my question is this: is there way define modified rows() function that can give me result: for vector - number of rows and for scalar - 1.
I'm using solve() to get results and saving those under "M", then I'm defining N:=rows(M), and that is point where trouble starts - solve() can give results
in form of either vector or scalar, depending on the function used in it and if result "M" is scalar rows(M) fails.
So my question is this: is there way define modified rows() function that can give me result: for vector - number of rows and for scalar - 1.
#2 Posted: 10/26/2015 7:31:49 PM
Hello Veldirn,
You can take advantage of the stack(1) function; when a single argument is used in stack(...), the functions returns the argument itself if it is a matrix/vector, a 1x1 matrix if it is a number.
Therefore to accomplish your task you can define M as M:stack(solve(...)).
You can take advantage of the stack(1) function; when a single argument is used in stack(...), the functions returns the argument itself if it is a matrix/vector, a 1x1 matrix if it is a number.
Therefore to accomplish your task you can define M as M:stack(solve(...)).
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
1 users liked this post
Veldirn 10/27/2015 3:40:00 AM
#3 Posted: 10/27/2015 3:41:55 AM
Thank you!
I knew there must be some function that can help. Already tested stack() solution and it works. Now I can finish my work.
I knew there must be some function that can help. Already tested stack() solution and it works. Now I can finish my work.
#4 Posted: 10/27/2015 1:05:44 PM
I dont see my reply from last night ,,, never mind
___________________________________
There is nothing to stack from either Roots or solve
Convince yourself, write like this
sol:=solve(sin(x),x,-10,10)
... it will solve for the roots within the specified range.
now, write sol=
and see all the roots stacked
Now, there is a MOST important nuance wrt further processing down the work sheet.
Assume you need to continue the project involving the roots, you should isolate
the roots by copying the vector of the roots in a new vector r:=[paste the vector of sol]
By not isolating, the part of the project will keep recalculating the roots.
In many instances it slows down the work and may fail to conclude on involved task.
cheers, Jean
___________________________________
There is nothing to stack from either Roots or solve
Convince yourself, write like this
sol:=solve(sin(x),x,-10,10)
... it will solve for the roots within the specified range.
now, write sol=
and see all the roots stacked
Now, there is a MOST important nuance wrt further processing down the work sheet.
Assume you need to continue the project involving the roots, you should isolate
the roots by copying the vector of the roots in a new vector r:=[paste the vector of sol]
By not isolating, the part of the project will keep recalculating the roots.
In many instances it slows down the work and may fail to conclude on involved task.
cheers, Jean
1 Pages (4 items)
-
New Posts
-
No New Posts