Hello Farimani,
Le 19/02/2019 à 10:47, farimani a écrit :
As I have originally explained in this post
<https://stackoverflow.com/questions/54756985/expression-block-in-xcos-gives-answer-given-for-scilab-expression-is-wrong-err>
I'm trying to put the SciLab expression:
sign(u2 – u1) * (2 * ((Fm + M) * abs(u2 – u1) + k * (u2^2 – u1^2) / 2) /
m)^0.5
but I get this error message:
<http://mailinglists.scilab.org/file/t497909/7ivdz.png>
answer given for scilab expression is incorrect...
I would appreciate if you could help me know what is the problem and how I
can solve it. Maybe I should use a different block?
Copy/pasting your formula in the console:
[Fm, M, m, k] = (1,1,1,1);
[u1, u2] = (1,2);
r = sign(u2 – u1) * (2 * ((Fm + M) * abs(u2 – u1) + k * (u2^2 – u1^2) / 2) /m)^0.5; --> r = sign(u2 – u1) * (2 * ((Fm + M) * abs(u2 – u1) + k *
(u2^2 – u1^2) / 2) /m)^0.5;r = sign(u2 – u1) * (2 * ((Fm + M) * abs(u2 –
u1) + k * (u2^2 – u1^2) / 2) /m)^0.5;^~~^Error: syntax error, unexpected
identifier, expecting "," or )
Puzzling... Hard to find why, but finally:
You have likely copy/pasted this formula from a "formatted" document,
maybe a web site, etc.
Then, the included "–" character is not the mathematical minus, that is "-".
This puzzles the Scilab's parser.
If you input the same formula, just replacing the hyphens with the true
minus, it works,
in the console as well as in Xcos.
--> r = sign(u2 - u1) * (2 * ((Fm + M) * abs(u2 - u1) + k * (u2^2 -
u1^2) / 2) /m)^0.5
r =
2.6457513
HTH
Samuel
_______________________________________________
users mailing list
[email protected]
http://lists.scilab.org/mailman/listinfo/users