How can I use the input command to ask the user to enter an equation?

4 ビュー (過去 30 日間)
Abdullah Nabi
Abdullah Nabi 2020 年 4 月 18 日
コメント済み: Abdullah Nabi 2020 年 4 月 18 日
I want to write a command which will allow the user to enter an equation in terms of x and also, ask the user to enter the value of the variable x.

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 4 月 18 日
See this example
str = 'sin(x)*exp(x)'; % input function in term of x
f = str2func(['@(x)' str]); % convert to MATLAB function
x = 2; % evaluate at x=2
f(2) % evaluate the function

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

タグ

製品


リリース

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by