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

2 vues (au cours des 30 derniers jours)
Viraj
Viraj le 26 Août 2024
Commenté : DGM le 27 Août 2024
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.

Réponses (1)

DGM
DGM le 26 Août 2024
Modifié(e) : DGM le 26 Août 2024
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 commentaires
Voss
Voss le 26 Août 2024
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.
DGM
DGM le 27 Août 2024
Oh good catch!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Entering Commands dans Help Center et File Exchange

Produits


Version

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by