im trying to implement a user-defined function

2 ビュー (過去 30 日間)
Chloe St John
Chloe St John 2019 年 1 月 25 日
コメント済み: Rena Berman 2019 年 3 月 5 日
im trying to a implement a function for the relationship:
ya = sin((2/(x+2))-3).^3
this is what i have as my code and nothing happens when i run the code:
function [ya] = a3(x)
ya = sin((2/(x+2))-3).^3
end
dont really know what to do from here..
i have saved the file as a3.m
in the command window it says:
Function with duplicate name "a3" cannot be defined.
  1 件のコメント
Rena Berman
Rena Berman 2019 年 3 月 5 日
(Answers Dev) Restored edit

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

回答 (1 件)

Walter Roberson
Walter Roberson 2019 年 1 月 25 日
The "function with duplicate name a3" error happens in one of two circumstances:
  1. You have a .m file that accidentally has two "function a3" lines in it; or
  2. You have a script name a3.m that tries to define function a3. When you have a function defined inside a script file, the function name cannot be the same name as the script.
Script files are .m files for which the first executable word is not "function" or "classdef".

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by