Why am I getting "Unrecognized function or variable 'fp'."?

Tried to make a fixed point iteration code in MATLAB, but I am not sure why I am unable to call my function without receiving this error.

回答(1 个)

DGM
DGM 2024-8-26
编辑:DGM 2024-8-26
Functions which are local to a script or local to another function are not accessible outside that scope. If you want your function to be accessible, it needs to be written as a function, not a script with a local function. Delete all the non-comment lines prior to the function() definition (get rid of clc; clear all).

2 个评论

In addition to @DGM's advice, when calling the function, you'll need to use its file name:
>> fixedp(g,p0,tol,n)
Change the file name to fp.m if you want to use that name.

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Entering Commands 的更多信息

产品

版本

R2024a

标签

提问:

2024-8-26

评论:

DGM
2024-8-27

Community Treasure Hunt

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

Start Hunting!

Translated by