Difference between revisions of "Octave"
From Steak Wiki
Jump to navigationJump to search(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
Tips on GNU Octave | Tips on GNU Octave | ||
− | + | * Get some books | |
− | + | * It's inefficient on the CPU, so use it for fun and prototyping. | |
==argv== | ==argv== | ||
Line 78: | Line 78: | ||
# I dug into the bug tracker, and also dl'd source code. looks like i have an old version | # I dug into the bug tracker, and also dl'd source code. looks like i have an old version | ||
# installing debian 10 resolved this (could also have used backports in stretch). | # installing debian 10 resolved this (could also have used backports in stretch). | ||
+ | |||
+ | ==Database Package with Devuan 9== | ||
+ | Devuan ascii has octave 4.0. ascii backports has 4.4, but not octave-struct (without breaking in devuan). Must migrate to Devuan Beowulf to get full octave 4.4. |
Latest revision as of 06:52, 30 December 2020
Tips on GNU Octave
- Get some books
- It's inefficient on the CPU, so use it for fun and prototyping.
argv
# NOTE: numbers passed into argv are treated as (ascii) char # must convert with str2num, or some other e.g. (call script with ./script 20 #!/usr/bin/octave arg_list = argv(); HOWLONG=arg_list{1} # NOTE: numbers passed into argv are treated as (ascii) char # which means 0 is around 40 in binary. # must convert with str2num, or some other # cast() will not fix this (as it casts the binary) display("How long is: ") class(HOWLONG) news2 = str2num(HOWLONG) display("news2 is now: ") class(news2)
if loop
#don't forget quotes on numbers here #if HOWLONG == "1" # SQLQUERYNUM = 288; #elseif HOWLONG == "3" # SQLQUERYNUM = 288 * 3; #elseif HOWLONG == "7" # SQLQUERYNUM = 288 * 7; #elseif HOWLONG == "14" # SQLQUERYNUM = 288 * 14; #else #display("incorrect time to search") #display("Try, 1, 3, 7, 14") #exit(); #en
sprintf
- basic sprintf (req's quotes)
- val1="test"
- val2="something"
- sprintf("%s%s",val1,val2)
- if you want to assign to variable, sprintf(variable,"%s%s",val1,val2)
- won't work, but ofc
- newvar = sprintf("%s%s",val1,val2)
- will
call function with parenthesis or not
- dynamically generate print filename at runtime
- https://www.mathworks.com/matlabcentral/answers/148-how-do-i-dynamically-generate-a-file-name-for-save-in-matlab
- essentially, if you myvar = sprintf(something...)
- you have to print(myvar)
- not print myvar
- so parenthesis are required (but they are not always required for e.g. print)
invert Y axis
- display(p(:,2)) (all times)
- display(p(:,1)) (all values)
- vals = p(:,1)
- EDIT: the below was a bug.
- it appears you can't invert the (p(:,1)) in plot, with either common commands used to invert Y axis.
- these cmds are: axis(ij) after plot, as well as set(gca,'YDir','reverse');, and plot (flipud(p(:, 2)), p(:, 1)) (this latter one inverts only the X axis, not Y
- so instead, send it to a new variable
- flipud(vals)
- EDIT: this isn't what I want to do. it flips the array upside down. instead, I want the high end
- of the y axis to be at the bottom, and the low numbers to be at the top.
- https://savannah.gnu.org/bugs/?47223
- I dug into the bug tracker, and also dl'd source code. looks like i have an old version
- installing debian 10 resolved this (could also have used backports in stretch).
Database Package with Devuan 9
Devuan ascii has octave 4.0. ascii backports has 4.4, but not octave-struct (without breaking in devuan). Must migrate to Devuan Beowulf to get full octave 4.4.