cancel
Showing results for 
Search instead for 
Did you mean: 
JKova
Level 4
138 92 2 5
Message 1 of 6
1,252
Flag Post

Solved!

How to store a matrix in HP50g using LIBEVAL ?

HP Recommended
HP 50g

 Hello HP Community ,

I wanna know how to write and store matrix using LIBEVAL function ( or command ) , or some other function ( command ) if possible , in ALGEBRAIC Calculator mode .

But in the End , I want that function or command whatever to me , works in RPN mode and Algebraic mode , or if possible only in Algebraic mode , of course .

If You did not understand me , I , of course , write that code in RPN mode , but i want for that program to work properly (when I am excecuting him) in Algebraic mode , not getting an error or something else.

 

I know thath when I'm in RPN Calculator mode i write that like , let's use my matrix is AAA , :

 

<< # A2012h LIBEVAL 

'AAA' STO

5 AAA * 'B' STO

>>

 

Let's suppose that B is matrix multiplied with factor ( number ) 5 , and stored like matrix.

 

When I use that code I did not get any ERROR at all , because I work in RPN Calculator mode , but when i switched my Calculator mode into Algebraic , problems started for me .

How to solve that problem ?

I will purchase some pictures , that you Can see that

If anyone have an answer please reply !!

Thank you .

This is code for my program . ..This is code for my program . ..It is RPN calculator mode ...It is RPN calculator mode ...Here is the results of my calculatons , upper matrix is AAA down is B matrixHere is the results of my calculatons , upper matrix is AAA down is B matrixWhen I switch mode to Algebraic ...When I switch mode to Algebraic ...

I get error , i dont get it , everything looks well in RPN mode but now ... 

Excuse me error is ...These kind of error I get while I am in Alg.. calculator modeThese kind of error I get while I am in Alg.. calculator mode

I dont know how to solve that ...

 

Anyone If anyone knows thanks a lot !!!

 

 

0 Kudos
Tags (1)
5 REPLIES 5
David_M
Level 6
140 139 29 60
Message 2 of 6
Flag Post
HP Recommended

#A2012h LIBEVAL activates the same functionality as if you pressed LS ' (MTRW key).  Your program works in RPN mode because the result is returned to stack level 1 in that mode.  In algebraic mode, MTRW simply returns the matrix to the command line in string form, awaiting any further key presses (further editing, ENTER, or CANCEL).  As such, in that mode there's nothing yet "on the stack" ready to be stored.  Hence the error.

 

The easiest way to avoid this problem is simply not to use algebraic mode. :generic:  If for some reason you must, you could encapsulate the LIBEVAL call within a "forced RPN block" as follows:

«
  PUSH -95 CF
  #A2012h LIBEVAL
  POP
  'AAA' STO
  5 AAA * 'B' STO
»

PUSH saves the current flag settings, -95 CF sets the calculator to RPN mode, then POP restores the flag settings.  This makes sure that the LIBEVAL call will always be run in RPN mode, regardless of the calculator's current setting.

BartdB
Level 9
971 954 119 186
Message 3 of 6
Flag Post
HP Recommended

Hi,

 

As you are using LIBEVAL, I would suggest you continue using RPN mode.

 

(similarly if you use SYSEVAL or FLASHEVAL, as these xEVAL commands access functions directly and bypass error traps - this can lead to memory corruption or calculator crash if done incorrectly)

 

Several differences in syntax between RPN and ALG modes.

 

The syntax to execute a program:

for example a program named MYPRG that takes variables A and B as inputs

 

RPN mode:

...(stack levels)

2:                          A

1:                          B

then execute MYPRG

 

 

ALG mode:

on the stack enter:

MYPRG(A,B)

then press ENTER to execute

 

 

 

Other differences with respect to your program:

 

The syntax for storing a variable differs for ALG mode.

To store value in variable A

 

RPN: value  'A'  STO         

 

ALG: value  STO>  A

 

 

The syntax for operators is different, multiplication example:

To multiply value 1 & 2

 

RPN: value1  value2  *

 

ALG: value1  * value2

 

 

 

 

 

-Bart
_________________________________________________________
calculator enthusiast
0 Kudos
JKova
Author
Level 4
138 92 2 5
Message 4 of 6
Flag Post
HP Recommended

I get these sort of error : + Error : Too Few Arguments ( this is actualy last picture I don't how why is on first place )I get these sort of error : + Error : Too Few Arguments ( this is actualy last picture I don't how why is on first place )thank you college , 

I wanna know also how to write , as example when I'm going to calculate addition of number one and two in one cell of matrix ( or maybe more of them ) ,  when I'm going to function that You write in code frame I Can go to the Algebraic mode and store the result matrix , but when I want to calculate the addition ( or multiplication ) of two numbers I must enter that numbers and operator between

them like I am in RPN mode ( 1 2 + ) , so how to calculate 1+2 in one cell of matrix without using sign '1+2' , i want to calculate that number directly in Algebraic mode as 1+2 .

 I will show You my procedure in down picture ...

Here I write your code in my HP 50g calculator...Here I write your code in my HP 50g calculator...When I am going to calculate addition of two numbers in ALG mode but calculated as RPN  ( as you see ) ...When I am going to calculate addition of two numbers in ALG mode but calculated as RPN ( as you see ) ...The result is 3 , which is good , 1 added to 2 gives us 3 , but ....The result is 3 , which is good , 1 added to 2 gives us 3 , but ....... so when I'm going to calculate this addition in ALG mode as Alg expression without signs (' value1 + value2'  ) then when I'm going to do that In ALG mode I get ...... so when I'm going to calculate this addition in ALG mode as Alg expression without signs (' value1 + value2' ) then when I'm going to do that In ALG mode I get ...

 

0 Kudos
David_M
Level 6
140 139 29 60
Message 5 of 6
Flag Post
HP Recommended

Perhaps you're starting to understand why mixing operating modes is a messy concept on the 50g.  The program in my previous reply sets RPN mode exclusively before the matrix writer is invoked (regardless of your current mode), so the data entry it accepts is limited to valid RPN expressions.

 

A different approach can be used that leaves the mode intact (therefore allowing algebraic expressions while in that mode), but I haven't tested it thoroughly and it may present other problems.  It attempts to simulate the ENTER key being pressed after the matrix writer is invoked in algebraic mode, which may not even be a reasonable thing to do (depends on what the user did).  I haven't done extensive testing with this, but it appears to work in the case where you simply add some entries in the matrix writer and press enter to continue:

 

«
  -43.2 KEYEVAL
  IF -95 FS? THEN
    -105 KEYEVAL
    DROP
  END
  'AAA' STO
  5 AAA * 'B' STO
»

I also avoided the use of the LIBEVAL by using KEYEVAL, which is generally safer.

 

I still recommend that you simply stick with RPN mode, though.  You seem to be the type of person who wants to customize and automate your use of the 50g, and you will ultimately find more success sticking with RPN operations.

Tags (1)
JKova
Author
Level 4
138 92 2 5
Message 6 of 6
Flag Post
HP Recommended

Thank you David_M you show me the best answer , now I am going to calculate a squareroot , inverse , square , ... i don't know what else I can do with your "advice" ,..., and with no any problem in Algebraic calculator mode.
Ok I now that is very complicated to work with mixing calculator modes .
It is very useful to do some operations ( for me ) in Algebraic mode because when I am going to write some "heavy" equation ... as example squareroot of a squared plus b squared ... or some heavier function , the easy way to do this is with Algebraic calculator mode.

 

Anyway thank you , thank you , thank you , you give me an answer on question which I thought for solution at least two weeks :OpenSmile:

 

 

 

 

0 Kudos
† The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation