Post Reply 
Input function - bad argument value
06-07-2023, 05:04 PM (This post was last modified: 06-09-2023 07:31 PM by Amer7.)
Post: #1
Input function - bad argument value
Hi,
Folks I have a problem, my tasks became to complicated for me to calculate it all by hand ( I don't have enough time to complete the task)

How can I input a function like:
a1=d1*cos(alpha)+X
a2=d1*sin(beta)+Y
a3=d2*cos(beta)
a4=d3*sin(beta) ....

I can have Xx amount of these functions

And then tell the program to derivation of functions by variable that in input.
like alpha, beta, d1, d2

[Image: attachment.php?aid=12224]
As you can see these are stored in matrix
The issue is when I write the input program it doesn't let me input the function.
How can I make this on Prime?

1. Issue is how do I make first input screen to let me enter the numbers of how many inputs spaces I need.
2. How do I input the function


Attached File(s) Thumbnail(s)
   
Find all posts by this user
Quote this message in a reply
06-07-2023, 08:05 PM
Post: #2
RE: Input function
https://youtu.be/qSY6RXvAHuw

I will try this tomorrow maybe with a string?
will give feedback
Find all posts by this user
Quote this message in a reply
06-08-2023, 08:52 AM (This post was last modified: 06-09-2023 06:08 PM by Amer7.)
Post: #3
RE: Input function -Bad argument value
EXPORT CAK()
BEGIN

LOCAL a,i,c,b;
INPUT({{a,[-1]}},"String");
return a;

END;

Value -1, -2 allow me to input my function d*cos(alpha)

Now I need to ask the user how many input he wants, and then proceed to new input screen with
input fields that user declared.

I have tried to set this with simple IF loop.


This part somehow doesnt work
Code:
BEGIN
LOCAL a,i,c,b;
INPUT({a},"test", {"a"});  /// Input from user number
PRINT();
if(a!=0)
THEN
INPUT({{b,c,[2]}},"b","c");     /// new inpt
PRINT(b);
PRINT(c);
ELSE
PRINT("input cant be 0");       /// Eror if user inputs 0
END;

END;

The problem is if I enter 1, or any number it just throws me to the Error line, it doesnt offer me a new input screen.

EDIT; When i write it like this, I get input screen one, enter value, input screen two
Code:
EXPORT CAK()
BEGIN

LOCAL a,i,c,b;
INPUT({{a,[-1]}},"Varijabla");

INPUT({{b,[-1]}},"Varijabla");
i:=diff(a,b);

return(i);
END;

I get as a result bad argument value

Inputs are D1*cos(Alpha), D1

When I'm in calculator (HOME) and I input diff(D1*cos(alpha),D1) i get correct value of cos(Alpha)
Find all posts by this user
Quote this message in a reply
06-10-2023, 08:02 PM (This post was last modified: 06-10-2023 09:08 PM by Amer7.)
Post: #4
RE: Input function - bad argument value
Is there any way to write the function in a matrix like
d1*cos(alpha),d2*cos(alpha)... without it returning an Error?

Ok, when I MAKEMAT(0,3,1) and then i view it, end I edit the 0 to be my function. I can save it to some variable like Ss0. It will appear in matrix menu. I vectorize it.
But when i do the diff(Ss0(1)/Ss1(1)) it again throws an error bad argument value

"(expression,variable=value) Error Bad Argument Value"

   
   

I need to make this but with functions in x and y
[Image: 43b8c31f61f8b2bbe6f0df4d62012d8ba86ba420]

vector by vector derivative matrix

Guys I found some code for jacobian matrix, it compiles no Errors, but I doesn't want to run

Code:
#cas
jacob2(args):=
// Jacobian Matrix by Salvo Micciché
// input vectorial expression, vector of variables
BEGIN
local argv, argc, mat, f, var, fn, fg, j, k, gr, vd;
argv:=args;
argc:=size(argv);
IF argc !=2 THEN
return "Input:[f1(x),f1(y),f1(z)...], [x,y,z,...]";
ELSE
f:=argv(1);
var:=argv(2);
fn:=size(f);
vd:=size(var);
IF fn:=1 THEN
fg:=grad(f(1),var);
f:=fg;
fn:=size(f);
END;
mat:=makemat(0,fn,vd);
FOR j FROM 1 TO fn DO // gradients
gr:=grad(f(j),var);
FOR k FROM 1 TO vd DO // items
mat[j,k]:=factor(gr(k));
END; // for k
END; // for j
return mat;
END; // if-else
END;
#end

https://www.hpmuseum.org/forum/thread-3852.html

Ahhh, just type jacob() in home

EDIT: I think this solves my issue.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 2 Guest(s)