Working on M-files

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Working on M-files

Jackie Y.
To Whom It May Concern:

I am a college student who have installed Octave for my computer as an alternative to Matlab. I am very pleased that much, if not all of the syntax is exactly the same as Matlab. However, after reading on many sites, I do not understand how one will create and execute a m-file on octave. By typing in "edit" in the command line, Scite opens up. I can create a code in it, but I cannot save it. Furthermore, I cannot seem to copy and paste it into Octave's command line. I would like to know how to be able to create M-files in Octave, and how to run it in Octave. Because I am not very computer-savvy, I would appreciate if you would explain it to me in the simplest way. I appreciate your time and answers and thankyou for making such a magnificient program.

-- Jackie

_______________________________________________
Help-octave mailing list
[hidden email]
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Working on M-files

bharat pathak
1. open octave.
 
2. go to your workarea using cd command, example
 
   >> cd d:\temp
 
3. edit junk.m
 
4. remove all the contents of file.
 
5. put following content into file
 
    clear all;
    close all;
 
    for ii = 1 : 100
 
       printf('hello world \n');
    end
 
6. save the file in "d:\temp" area using "file-save as"
 
7. come to command window
 
    >> junk                        { hit enter }
 
8 hello world get's printed 10 times.
 
 
Regards
Bharat Pathak
 
Arithos Designs
 
DSP Design Consultancy and Corporate Training Company.
 
 
 
 

Sent: Monday, September 22, 2008 3:11 AM
Subject: Working on M-files

To Whom It May Concern:

I am a college student who have installed Octave for my computer as an alternative to Matlab. I am very pleased that much, if not all of the syntax is exactly the same as Matlab. However, after reading on many sites, I do not understand how one will create and execute a m-file on octave. By typing in "edit" in the command line, Scite opens up. I can create a code in it, but I cannot save it. Furthermore, I cannot seem to copy and paste it into Octave's command line. I would like to know how to be able to create M-files in Octave, and how to run it in Octave. Because I am not very computer-savvy, I would appreciate if you would explain it to me in the simplest way. I appreciate your time and answers and thankyou for making such a magnificient program.

-- Jackie


_______________________________________________
Help-octave mailing list
[hidden email]
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave

_______________________________________________
Help-octave mailing list
[hidden email]
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Working on M-files

Michael Goffioul
In reply to this post by Jackie Y.
On Sun, Sep 21, 2008 at 11:41 PM, Jackie Y. <[hidden email]> wrote:
> To Whom It May Concern:
>
> I am a college student who have installed Octave for my computer as an
> alternative to Matlab. I am very pleased that much, if not all of the syntax
> is exactly the same as Matlab. However, after reading on many sites, I do
> not understand how one will create and execute a m-file on octave. By typing
> in "edit" in the command line, Scite opens up. I can create a code in it,
> but I cannot save it.

What do you mean "you cannot save it"? What error message do you get?
Are you saving to a directory where you have write access?

> Furthermore, I cannot seem to copy and paste it into
> Octave's command line.

Copy and paste into octave command windows (which is actually
a Windows command prompt) is not intuitive. You have to click on the
icon on the left-side of the title bar and follow the "Edit" menu entry.

> I would like to know how to be able to create M-files
> in Octave, and how to run it in Octave. Because I am not very
> computer-savvy, I would appreciate if you would explain it to me in the
> simplest way. I appreciate your time and answers and thankyou for making
> such a magnificient program.

The simplest way is the following:
1) edit and save m-files with whatever text editor you like (octave comes
with SciTE, but you can use any other editor); save you files into any
directory you like, let's call it C:\My\Dir
2) in octave, add the save directory to the octave search path:

  addpath C:\My\Dir

3) run your m-files from octave prompt

One variant of this is to use the octave current working directory to
save your files (type "pwd" at octave prompt). As the current working
directory is automatically part of the octave search path, the files will
be always visible to octave. If you want to know more about octave
search path, see "help path" and "help addpath".

Michael.
_______________________________________________
Help-octave mailing list
[hidden email]
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave