octave

Octave does not plot

放肆的年华 提交于 2019-12-03 18:18:43
问题 When I try to plot a graph on GNU Octave, and try to use plot, it gives me the following output set terminal aqua enhanced title "Figure 1" size 560 420 font "*,6" dashlength 1 ^ line 0: unknown or ambiguous terminal type; type just 'set terminal' for a list I am using Mac OS X 10.9.2. I have tried using octave:79> setenv("GNUTERM","X11") but I still get the same error. 回答1: setenv("GNUTERM","qt") in your octave command prompt, it should solve the problem. 回答2: I think your problem comes from

How to load packages in Octave permanently?

痴心易碎 提交于 2019-12-03 15:48:16
问题 I am using Octave on Window vista. I am using 4 package in my code. But every time I restart octave, I have to load manually from command line, 'pkg load ...' Is there a way to load them permanently so that whenever Octave is started it finds them in its path. 回答1: When Octave starts, it runs ~/.octaverc . If you want Octave to automatically load a package, simply add a pkg load pkg-name command to it. If the files does not exist, create it. If you do this, remember that other people may not

global variable in octave

ε祈祈猫儿з 提交于 2019-12-03 14:24:35
global m = 1; function p = h() m end h() I'm trying to run this script, but I get this error: 'm' undefined near line 4 column 3 Say me please, how I can use the variable from functions? You have to declare the var also global inside the function as described here: https://www.gnu.org/software/octave/doc/interpreter/Global-Variables.html global m = 1; function p = h() global m; m endfunction h() 来源: https://stackoverflow.com/questions/27409364/global-variable-in-octave

Switching values to plot using keyboard input

ε祈祈猫儿з 提交于 2019-12-03 13:36:44
问题 I have sets of data in a matrix. I want to plot on set and then use a keyboard input to move to another one. It's simply possible this way: for t=1:N plot(data(:,t)) pause end but I want to move forward and backward in time t (e.g. using arrows). OK, it could be done like this: direction = input('Forward or backward?','s') if direction=='forward' plot(data(:,ii+1)) else plot(data(:,ii-1)) end but isn't there something more elegant? (On one click without getting the figure of the sight - it's

Binning in matlab

六月ゝ 毕业季﹏ 提交于 2019-12-03 13:12:23
问题 I have been unable to find a function in matlab or octave to do what I want. I have a matrix m of two columns (x and y values). I know that I can extract the column by doing m(:,1) or m(:,2). I want to split it into smaller matricies of [potentially] equal size and and plot the mean of these matricies. In other words, I want to put the values into bins based on the x values, then find means of the bins. I feel like the hist function should help me, but it doesn't seem to. Does anyone know of

Reset ColorOrder index for plotting in Matlab / Octave

*爱你&永不变心* 提交于 2019-12-03 12:27:33
I have matrices x1, x2, ... containing variable number of row vectors. I do successive plots figure hold all % or hold on plot(x1') plot(x2') plot(x3') Matlab or octave normally iterates through ColorOrder and plot each line in different color. But I want each plot command to start again with the first color in colororder , so in default case the first vector from matrix should be blue, second in green, third in red etc. Unfortunately I cannot find any property related to the color index niether another method to reset it. You can shift the original ColorOrder in current axes so that the new

Calling .csv file into Octave

杀马特。学长 韩版系。学妹 提交于 2019-12-03 12:03:06
I have a code written in C++ that outputs a .csv file with data in three columns (Time, Force, Height). I want to plot the data using Octave, or else use the octave function plot in the C++ file (I'm aware this is possible but I don't necessarily need to do it this way). Right now I have the simple .m file: filename = linear_wave_loading.csv; M = csvread(filename); Just to practice bringing this file into octave (will try and plot after) I am getting this error. error: dlmread: error parsing range What is the correct method to load .csv files into octave? Edit: Here is the first few lines of

Euclidean distance between two vectors (single row matrix)

情到浓时终转凉″ 提交于 2019-12-03 11:58:55
问题 I have two vectors (single row matrices). Assume that we already know the length len . A = [ x1 x2 x3 x4 x5 .... ] B = [ y1 y2 y3 y4 y5 .... ] To calculate Euclidean distance between them what is the fastest method. My first attempt is: diff = A - B sum = 0 for column = 1:len sum += diff(1, column)^2 distance = sqrt(sum) I have loop through this methods millions of times. So, I am looking for something which is fast and correct. Note that I am not using MATLAB and don't have pdist2 API

How can I set the window size of a plot window?

≡放荡痞女 提交于 2019-12-03 10:33:54
Is it possible to set the window size / position of a plot window (figure)? plot(0:20, sin(0:20)) Or is there any other possibility to change the size of the print() command? print('aa.png', '-dpng') Because the -Sxsize,ysize parameter doesn't change anything. The size of the written picture (aa.png) has always the same size as the plot window. I'm using Octave 3.0. Yes, it is possible: figure(1, 'position',[startx,starty,width,height]); plot(0:20,sin(0:20)); [startx,starty] are the coordinates for the lower left corner of your figure (window). You can also use the resolution option of the

Display struct fields without the mess

喜欢而已 提交于 2019-12-03 10:20:04
问题 I have a struct in Octave that contains some big arrays. I'd like to know the names of the fields in this struct without having to look at all these big arrays. For instance, if I have: x.a=1; x.b=rand(3); x.c=1; The obvious way to take a gander at the structure is as follows: octave:12> x x = scalar structure containing the fields: a = 1 b = 0.7195967 0.9026158 0.8946427 0.4647287 0.9561791 0.5932929 0.3013618 0.2243270 0.5308220 c = 1 In Matlab, this would appear as the more succinct: >> x