Home > Archive > Matlab > June 2007 > Matlab Functions
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| Dear All,
I have been reading 'Adaptive Filters with Matlab Primer', published
by CRC Press.
Algorithms can be downloaded at the publisher's website.
I have downloaded these but have trouble actually running the m
files. I get a prompt telling me that function cannot be used at the
prompt.
Can anyone advise on what I am doing wrong, please?
Thanks in advance.
Kindest regards,
Kevin.
| |
| Steven Lord 2007-06-27, 10:12 pm |
|
"Kevin" <kevinteyhan@hotmail.com> wrote in message
news:ef5bd3f.-1@webcrossing.raydaftYaTP...
> Dear All,
>
> I have been reading 'Adaptive Filters with Matlab Primer', published
> by CRC Press.
> Algorithms can be downloaded at the publisher's website.
> I have downloaded these but have trouble actually running the m
> files. I get a prompt telling me that function cannot be used at the
> prompt.
>
> Can anyone advise on what I am doing wrong, please?
>
> Thanks in advance.
>
> Kindest regards,
>
> Kevin.
It sounds like you're copying the contents of the functions and pasting them
into the Command Window. That's not the right way to call functions. Put
the functions into a directory, then go to File -> Set Path (or use the
function PATHTOOL) to add the directory containing those functions to the
MATLAB path, then call them like you'd call any other function in MATLAB.
http://www.mathworks.com/access/hel.../f10-26235.html
--
Steve Lord
slord@mathworks.com
| |
| Kevin 2007-06-27, 10:12 pm |
| Kevin wrote:
>
>
> Dear All,
>
> I have been reading 'Adaptive Filters with Matlab Primer',
> published
> by CRC Press.
> Algorithms can be downloaded at the publisher's website.
> I have downloaded these but have trouble actually running the m
> files. I get a prompt telling me that function cannot be used at
> the
> prompt.
>
> Can anyone advise on what I am doing wrong, please?
>
> Thanks in advance.
>
> Kindest regards,
>
> Kevin.
| |
| Kevin 2007-06-27, 10:12 pm |
| Hello Steven,
Thank you for taking the time to reply. I did as you suggested, but
unfortunately I am still having problems. Here are the actions I
took:
I did File, then Set Path.
My ‘Current Directory’ window then showed the list of .m files.
I then right clicked on the .m file I wanted and selected ‘Open’.
This opened the Editor screen.
From there, I copied and pasted the first line of text “function
[w,y,e,J,w1]=aalms1(x,dn,mu,M)” in to the Command window.
This returned “Error: Function definitions are not permitted at the
prompt or in scripts”
I then tried right clicking on the .m file in ‘Current Directory’
window and selected run. This returned
“??? Input argument “x” is undefined
Error in = = > aalms1 at 12
N = length(x);”
I am still unable to get any joy. Could you please excuse my
stupidity and advise where I am going wrong. I would be sincerely
grateful.
Kindest regards,
Kevin.
| |
| Walter Roberson 2007-06-27, 10:12 pm |
| In article <ef5bd3f.2@webcrossing.raydaftYaTP>,
Kevin <kevinteyhan@hotmail.com> wrote:
>I did File, then Set Path.
>My ‘Current Directory’ window then showed the list of .m files.
>I then right clicked on the .m file I wanted and selected ‘Open’.
>This opened the Editor screen.
>From there, I copied and pasted the first line of text “function
>[w,y,e,J,w1]=aalms1(x,dn,mu,M)” in to the Command window.
>This returned “Error: Function definitions are not permitted at the
>prompt or in scripts”
If the text is already in a .m file and the directory for that
..m file is already on your path, then you don't need to do anything more.
Just invoke the function name with whatever arguments you want... e.g.,
aalms1([1:3:30], 3, 0.04, 50)
(these arguments were chosen randomly, without looking around to see
what kind of arguments the function actually expects.)
--
"No one has the right to destroy another person's belief by
demanding empirical evidence." -- Ann Landers
| |
|
| Walter Roberson wrote:
>
>
> In article <ef5bd3f.2@webcrossing.raydaftYaTP>,
> Kevin <kevinteyhan@hotmail.com> wrote:
‘Open’.[color=darkred]
> the
>
> If the text is already in a .m file and the directory for that
> .m file is already on your path, then you don't need to do anything
> more.
> Just invoke the function name with whatever arguments you want...
> e.g.,
>
> aalms1([1:3:30], 3, 0.04, 50)
>
> (these arguments were chosen randomly, without looking around to
> see
> what kind of arguments the function actually expects.)
> --
> "No one has the right to destroy another person's belief by
> demanding empirical evidence." -- Ann Landers
>
Thanks Walter,
Your help was greatly appreciated.
Kindest regards,
Kevin
|
|
|
|
|