How do I design a graphing calculator with this condition.

7 ビュー (過去 30 日間)
Kiha Kim
Kiha Kim 2022 年 2 月 3 日
移動済み: Voss 約15時間 前
I'm need to use disp, input, fevel and plot function.
I have 5 options for functions: Sin, Cos, Tan, Log, Exp.
  1. I'm going to ask the choice of function and take it as the input to my program.
  2. And ask the domain of function and take it as another input.
  3. Include x-label, y-label, title, and grid line.
  1 件のコメント
Rik
Rik 2022 年 2 月 3 日
This looks like homework to me. What did you try?

サインインしてコメントする。

回答 (1 件)

Voss
Voss 2022 年 2 月 3 日
移動済み: Voss 約15時間 前
This will create a cell array of handles to your functions:
funcs = {@sin @cos @tan @log @exp};
Then you can get user input for selecting a function using input(), say an integer between 1 and 5. Call it idx.
Then you can get user input for specifying a domain using input(), say a 1-by-2 vector of doubles. Call it domain.
Then you can execute the selected function over that domain like so:
x = linspace(domain(1),domain(2),100); % 100 equally-spaced x values
y = feval(funcs{idx},x); % value of the function at each x value
Then plot and add grids, labels and title.

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by