How do I plot given points using a functions?

10 ビュー (過去 30 日間)
Abigail Sebright
Abigail Sebright 2020 年 11 月 25 日
編集済み: Stephan 2020 年 11 月 25 日
Say I have the points x = 1,12,2,6,5 and y = 5,23,5,6,3 which are not related. I know i can plot them using plot(x,y), but how do i do this using a function?

回答 (1 件)

Stephan
Stephan 2020 年 11 月 25 日
編集済み: Stephan 2020 年 11 月 25 日
x = [1,12,2,6,5]
y = [5,23,5,6,3]
plot(x,y)
% Using a function handle
y_fun = @(x) 3.*x + 5;
y_vals = y_fun(x);
plot(x, y_vals)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by