How to let a user input a function

Jal Rhee Ducusin Malugao

I know that the input syntax in scilab looks like this:

result = input ("Enter your number: ")

My problem is, how can I enter a function like cos(x) + sin(x) ?

user6655984

Let the user enter a string (parameter "s" of the input command), and use this string in eval command for evaluation. Example:

fstr = input("Enter a function of x: ", "s")
x = input("What is the value of x: ")
y = eval(fstr) 
disp("The value of function is " + string(y))

The string evaluation can be wrapped as a Scilab function, too:

fstr = input("Enter a function of x: ", "s")
function y = f(x)
    y=eval(fstr)
endfunction

t = linspace(0, 2)
plot(t, f(t))

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to let user use "sqrt()" + input to find square root of input?

From Dev

Python: How to let the user input their own solution to the answer key

From Dev

How to let the user select an input from a finite list?

From Dev

Swift: How to let background thread wait for user input?

From Dev

How would I only let the user input one character in c

From Dev

Python: How to let the user input their own solution to the answer key

From Dev

How would I only let the user input one character in c

From Dev

Let the user input the name again

From Dev

How to display user input with a Javascript function

From Dev

How take *args input from user in a function

From Dev

bash let variable default to user input

From Dev

How to make function run, then wait for user input, then another function run?

From Dev

How to stop CasperJS execution and let the user input some value and then continue to execute?

From Dev

How to let user pick colormap?

From Dev

How to not let the user divide by 0?

From Dev

Pick a function by user input

From Dev

Get user input for function

From Dev

Get user input for function

From Dev

How to run a function when user presses enter on input field?

From Dev

How do I pass a user input as an argument into a function prototype?

From Dev

How to create a javascript function that will remember the user input and then display summary

From Dev

How to ask the user to input a mathematical function in c language?

From Dev

How to make the return value of a function user input-able in python

From Dev

Haskell: How to read user input to be used in a function inside of a do block?

From Dev

How to write a bash function that saves user input to new variable names

From Dev

How do you print a function from user input?

From Dev

c++: How to take user input as a function argument?

From Dev

Calling a function recursively for user input

From Dev

input by the user is not obtained by onblur function

Related Related

  1. 1

    How to let user use "sqrt()" + input to find square root of input?

  2. 2

    Python: How to let the user input their own solution to the answer key

  3. 3

    How to let the user select an input from a finite list?

  4. 4

    Swift: How to let background thread wait for user input?

  5. 5

    How would I only let the user input one character in c

  6. 6

    Python: How to let the user input their own solution to the answer key

  7. 7

    How would I only let the user input one character in c

  8. 8

    Let the user input the name again

  9. 9

    How to display user input with a Javascript function

  10. 10

    How take *args input from user in a function

  11. 11

    bash let variable default to user input

  12. 12

    How to make function run, then wait for user input, then another function run?

  13. 13

    How to stop CasperJS execution and let the user input some value and then continue to execute?

  14. 14

    How to let user pick colormap?

  15. 15

    How to not let the user divide by 0?

  16. 16

    Pick a function by user input

  17. 17

    Get user input for function

  18. 18

    Get user input for function

  19. 19

    How to run a function when user presses enter on input field?

  20. 20

    How do I pass a user input as an argument into a function prototype?

  21. 21

    How to create a javascript function that will remember the user input and then display summary

  22. 22

    How to ask the user to input a mathematical function in c language?

  23. 23

    How to make the return value of a function user input-able in python

  24. 24

    Haskell: How to read user input to be used in a function inside of a do block?

  25. 25

    How to write a bash function that saves user input to new variable names

  26. 26

    How do you print a function from user input?

  27. 27

    c++: How to take user input as a function argument?

  28. 28

    Calling a function recursively for user input

  29. 29

    input by the user is not obtained by onblur function

HotTag

Archive