Trouble with rows()

Trouble with rows() - Trouble with rows(X) when X is scalar. - Сообщения

#1 Опубликовано: 26.10.2015 10:47:35
Veldirn

Veldirn

0 сообщений из 4 понравились пользователям.

Группа: User

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.
#2 Опубликовано: 26.10.2015 19:31:49
Davide Carpi

Davide Carpi

1415 сообщений из 2872 понравились пользователям.

Группа: Moderator

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(...)).
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
1 пользователям понравился этот пост
Veldirn 27.10.2015 03:40:00
#3 Опубликовано: 27.10.2015 03:41:55
Veldirn

Veldirn

0 сообщений из 4 понравились пользователям.

Группа: User

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.
#4 Опубликовано: 27.10.2015 13:05:44
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

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
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений