HELP need to run Chebyshev code!
8 views (last 30 days)
Beata Dongwi on 22 Sep 2022
I have been trying to run the following code in MATLAB but to no avail. My version is really outdated. R2007b
%%Matlab code for Chebeval
%all given x
%chebeval matrix for given N
%plotting all N=0 to 5
%function for chebeval
When I ran the code from the Editor window, I get the following message:
??? Error: File: ChebevalNUMAssignment1.m Line: 18 Column: 1
Function definitions are not permitted at the prompt or in scripts.
And if paste it and run it from the command window, I get the following message:
??? Undefined function or method 'chebeval' for input arguments of
So, what should I do? Please help me, I tried so many times and I am new to MATLAB
Bjorn Gustavsson on 22 Sep 2022
Save your chebeval-function in a separate file chebeval.m. Then call that function from your script. For now you can put both script and function in the same working directory.
This way it becomes far easier to reuse the functions you write later on. That way you build up a set of tools which makes your programming incrementally stronger since you start to have tools to solve more complex problems later on, or at least tools that almost solves those problems and you only need to make smaller modifications to develop the new solution.
Once you've taken this step you will at some stage realize that it is preferable to organise your tools/functions in a better way and then you can group similar tools into toolboxes/different directories.