Creating a function that outputs a polynomial

2 ビュー (過去 30 日間)
Mitchell
Mitchell 2019 年 2 月 28 日
コメント済み: madhan ravi 2019 年 2 月 28 日
Please write a MATLAB function with the following: (1) output a third-order polynomial function with the coefficients as the input variables; (2) Convert this function to function handle.
  3 件のコメント
Mitchell
Mitchell 2019 年 2 月 28 日
poly3=@(x) -x.^3-2*x+exp(-x)
Mitchell
Mitchell 2019 年 2 月 28 日
I'm honestly just confused on what it's asking and how to create that function.

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

回答 (1 件)

Kevin Phung
Kevin Phung 2019 年 2 月 28 日
編集済み: Kevin Phung 2019 年 2 月 28 日
tip: When you create a new function on matlab (right click directory>new file > function), it looks something like this:
function [outputArg1,outputArg2] = func_name(inputArg1,inputArg2)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
outputArg1 = inputArg1;
outputArg2 = inputArg2;
end
defining a function this way is useful because you can call a result it with these inputs:
func_name(1,2)
note: you should save the name of the file to be the same as the name of your function.
so in this case, this file will be saved as func_name.m
  1 件のコメント
madhan ravi
madhan ravi 2019 年 2 月 28 日
[out1,out2]=func_name(1,2)

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by