Mon 01 Oct 2012 06:22:09 PM UTC, comment #15:
Matlab does:
First, it does a test:
>> run 'foo.m'
??? Undefined variable "foo" or class "foo.m".
Error in ==> run at 74
evalin('caller',[script ';']);
=================
This appears to test for .m as the suffix.
If foo.m is copied to foo, Matlab runs it
if it is a "script" (no .m) with or without
the first line: function [ ret ] = foo().
It appears to just ignore the first line.
I would say that the Matlab behaviour is about as
confusing as the current Octave behaviour.
It might be better if Octave threw an error
if foo.m is a function, but ran it if it is a script.
This would decided if it contains a function
declaration.
The fact that Matlab will not run a "script" who's
name ends with suffix .m seems, to me, not very
reasonable. But, I would not much object to this
bit of "Matlab compatibility."
|
Mon 01 Oct 2012 05:49:15 PM UTC, comment #14:
The "run" command is intended to run scripts that are not located somewhere on the path.
Maybe "run" should warn or throw an error when it is asked to run a function? What does Matlab do?
|
Mon 01 Oct 2012 05:40:56 PM UTC, comment #13:
Maybe 'run' should be 'execute'. But,
why does no output appear for run foo.m?
Isn't this a bug?
|
Mon 01 Oct 2012 05:35:11 PM UTC, comment #12:
Yeah, I would avoid mentioning "run" in the warning.
|
Mon 01 Oct 2012 05:24:44 PM UTC, comment #11:
function [ ret ] = foo()
printf ("Hello!\n");
endfunction
Now, issuing
foo
differs from
run foo.m
in the sense that the latter doesn't emit any output:
(Octave-3.6.2_MSVC)
...so there's the next pitfall looming for unwary users / n00bs.
|
Mon 01 Oct 2012 12:53:24 PM UTC, comment #10:
This is a good idea. Would a warning (or maybe error)
Would something like:
`foo.m' appears to be a script
file or it is not in `load' format. Script files are
run by `foo.m.' See 'help load' for use of the load command.
be clearer?
|
Mon 01 Oct 2012 12:30:05 PM UTC, comment #9:
Newbies keep trying to execute m-files with the load command. Any suggestion on the wording for a warning against this? I'm thinking something like "warning: attempting to load data from executable script `foo.m'. Consider `foo' or `run foo.m' instead."
|
Sun 30 Sep 2012 07:22:37 PM UTC, comment #8:
Sorry to all. I apparently have a major misunderstanding about Octave. Please ignore my posts and thanks for the help. I'll read everything I can find in the manual before I post again.
|
Sun 30 Sep 2012 04:20:51 PM UTC, comment #7:
You said:
"3. The contents of the files which fail can be entered from the
keyboard and run OK. "
But, this is not relevant to the use of the load command.
The load command, as the documentation explains, is for
loading variables into Octave.
|
Sun 30 Sep 2012 04:10:38 PM UTC, comment #6:
It would make it much easier to understand your
problem if you could provide the name of a ".m" file which
fails to load.
|
Sun 30 Sep 2012 04:05:59 PM UTC, comment #5:
Please reread my original post.
1. I am able to load and run some 'm' files without problem.
2. Some files fail to load and report matrix dimension errors.
3. The contents of the files which fail can be entered from the
keyboard and run OK.
4. All files under discussion are part of the distribution.
My question was not "how to execute an *.m file, but whether
anyone has seen a problem with files from the distribution failing
to run, when the same file data entered from the keyboard will work?
|
Sat 29 Sep 2012 10:53:26 PM UTC, comment #4:
If you want Octave to execute a *.m file,
just type its name.
|
Sat 29 Sep 2012 10:51:37 PM UTC, comment #3:
Have you tried "help load"
The load command is used for loading a file which contains
Octave data. Do your *.m files contain valid Octave
data?
|
Sat 29 Sep 2012 10:44:32 PM UTC, comment #2:
I simply type "load filename.m" at the prompt. I didn't think any transcript would be useful, because some files load and run OK, but others won't load and I get an error message "unable to determine size of matrix" or other error indicating mismatched rows or columns. Again, these files are in the distribution and when I key them in from the keyboard, they work fine.
|
Sat 29 Sep 2012 09:40:46 PM UTC, comment #1:
Exactly ho do you invoke those .m files?
Do you have a short transcript from an Octave session showing the errors?
|
Sat 29 Sep 2012 03:18:26 PM UTC, original submission:
I installed Octave on a Samsung laptop running Windows 7, 64-bit. Many, if not most, of the m files supplied with this distribution abort with errors -- usually failure to determine matrix size, or incompatible matrix dimensions. When I key the same file contents from the keyboard, they work fine. It seems there is some problem in the load file function. Has anyone else seen this problem? Is there some way to modify the files so they read properly?
|