I have GNU Octave 5.2.0, and I want to use it to analyze the IQ data in a wav file. This link describes a function called wavread which I can use in Octave, but when I run y = wavread(filename), I get this error message:
error: 'wavread' undefined near line 1 column 1
Why do I get this? My best guess is that wavread is deprecated for some reason and only exists in earlier versions. My other guess is that I have to install an extension to use wavread, but I didn't find a source that allows me to do this.
As discovered by #TasosPapastylianou, the wavread function is deprecated as of Octave version 5. Solution is to use audioread function.
I'm trying to analyze the system
20*e(0.9*s)
-------------
(s+10)
using GNU octave and the control package, but I cannot find the way to introduce the exponential (the exp octave function does not work).
The code I tried to write is
pkg load control
s = tf('s')
g = 20*exp(0.9*s)/(s+10)
but the following error is shown: error: exp: not defined for class
I tried searching the web a bit, without success.
Thanks in advance
Is it possible to make the markers (zeros and poles) from rlocus on Octave?
I've found the following answer, but the file that is supposed to be modified does not seem to be used anymore, or at least I wasn't able to find it with locate on Linux.
https://electronics.stackexchange.com/questions/372728/octave-rlocus-format-ploles-and-zero
This is the code I'm using to generate the plot.
pkg load control;
s = tf ('s');
GH = (s + 1)/(s*(s + 2))
rlocus (GH);
This is the plot generated by the code:
But the poles and zeros are almost invisible on the standard plot.
Thanks in advance for any responses.
From within octave, type
which rlocus
on the terminal.
This will tell you the location of the file in your current octave / control-package installation.
You can then proceed and edit the file as per the instructions of the previous post.
For my summer programming course I need to compile and test several functions from an ocaml file (a .ml file) our teacher gave us. I've never programmed in ocaml before, but I downloaded it on my ubuntu vm and not I can't figure out how to compile it and test the functions from the terminal.
I'm also curious if I need to add print statements to the code in order to test them, since ocaml doesn't require main methods. If so, how do I print the return value of a function?
Thank you for your help, I apologize if this is a newbie question.
Make sure that you have installed OCaml properly, by running the OCaml interactive toplevel (don't type $ this is a prompt from your shell):
$ ocaml
It should show something like this:
OCaml version 4.07.0
#
The # symbol is a prompt, you can type OCaml definitions there and send them to the interpreter using the ;; terminating sequence (again don't type # it is also a prompt symbol), e.g.,
# print_endline "Hello, world";;
Hello, world
- : unit = ()
#
Hint: to enable history install rlwrap with sudo apt install rlwrap and run the ocaml toplevel as
$ rlwrap ocaml
Now, we are ready to compile our first program. In OCaml, like in Python, all top-level definitions in your program are evaluated in order of their appearance, therefore you don't need to have a special main function. Despite this fact, I'm usually defining one, using the following idiom
let main () =
print_endline "Hello, world"
(* the entry point - just call the main function *)
let () = main ()
Now, create a new folder (make sure it is empty)
$ mkdir my-first-ocaml-program
$ cd my-first-ocaml-program
and put the OCaml code above into a file named test.ml (the filename doesn't have any special meaning for the compiler toolchain, but I will reference this name in the shell commands below).
let's test that everything is correct, by printing the contents of the test.ml file
$ cat test.ml
and the output should be
let main () =
print_endline "Hello, world"
(* the entry point - just call the main function *)
let () = main ()
Now, let's compile and run at the same time,
$ ocamlbuild test.native --
And we should see the "Hello, world",
Finished, 4 targets (4 cached) in 00:00:00.
Hello, world
The first line is the output from the compiler (ignore it, unless it is different). Starting from the second line it is our output. Here are some explanations on the build one-liner, ocamlbuild test.native. It uses ocamlbuild, an easy to use but powerful OCaml build tool. The test.native tells ocamlbuild that you want to build a native (machine code) binary and that test.ml is the main source file. You can also ask to build a bytecode binary, e.g., test.byte. This is called a target in ocamlbuild parlance. The -- is optional, and it tells ocamlbuild to run the built target as soon as it is ready. Any argument past -- is passed to your program as command line arguments.
What about larger programs or programs with dependencies? The good news is that you can put your code in several files in the same folder, and ocamlbuild will be clever enough to build them in the proper order (it will do the dependency analysis, compiling, and linking for you - all seamlessly). If you need to use some external package, then you can specify it via the -pkg option. For example, let's assume that we're using the fileutils package to implement our version of the ls program1. Let's update our test.ml so that it now is having the following contents:
$ cat test.ml
let main () =
FileUtil.ls "." |> List.iter print_endline
(* the entry point - just call the main function *)
let () = main ()
and, as usual, build and print in one
$ ocamlbuild -pkg fileutils test.native --
Finished, 4 targets (4 cached) in 00:00:00.
./test.native
./_build
./test.ml
1) How to install a package is system dependent. E.g., if you're using apt to install OCaml then you can do sudo apt install libfileutils-ocaml-dev. If you're using opam (the recommended way), then it is just opam install fileutils. In any case, package installation is out of the scope of this question, I'm assuming that in your course you would be using some packages pre-installed. We use fileutils here just as an example, which you can easily adapt to your own purposes.
I am trying to tranlate Matlab code in Octave. I am looking for Date Timer picker. I am affraid that there is no such utility in Octave. If so, is there any alternate for this Matlab command in Octave.
uicalendar();
Using Octave: error: 'uigetdate' undefined
Do I need some package etc. Any solution?
The function uigetdate does not exist in Octave core. It also does not exist in Matlab so I don't know where you got it from.
However, there is a function to pick a date from a calendar in the Octave zenity package. The zenity package is unmaintained but seems to still works fine.
octave> pkg load zenity
octave> date = zenity_calendar ()
date = 13-Nov-2017
Which will look like this on my system (Gnome 3):
The Octave zenity package is a wrapper to the zenity program so you will need to have it installed in your system.