octave

Matrix creation Octave / Matlab, loopless solution request

末鹿安然 提交于 2019-12-06 13:34:30
I want to create a matrix like A = [0 0 0 0 1; 0 0 0 1 1; 0 0 0 1 1; 0 0 0 1 1; 0 0 1 1 1; 0 1 1 1 1] based on a vector indicating how many '0's should precede '1's on each row: B = [4 3 3 3 2 1] Is there a loopless way to do this ? You don't mention in your question how the horizontal size of the array should be defined (the number of ones). For predefined width you can use this code: width = 5; A = cell2mat(arrayfun(@(x) [ zeros(1,x), ones(1,width-x) ], B, 'UniformOutput', false)'); If you want that A has minimal width, but still at least one 1 in every row: A = cell2mat(arrayfun(@(x) [

Octave: LaTeX tics

こ雲淡風輕ζ 提交于 2019-12-06 12:13:06
In GNU Octave I would like to set the tics of a plot as fractions. So instead of 0.0078125 (which is equal to 1/128) I would like to write "\frac 1 128". I tried already set(gca,'xTickLabel',{'\frac 1 128'}); but it does not work. The text '\frac 1 128' is not interpreted as LaTeX code. latex isn't implemented yet in GNU Octave. You can use a subset of TeX for Greek symbols and so on. If you just want to have LaTex in the generated print (for publication), you can use for example the device epslatexstandalone and render it afterwards with latex : close all graphics_toolkit fltk title ("for

Implementation of Matlab's uicontrol in Octave?

蓝咒 提交于 2019-12-06 11:35:17
I am trying to run the .m Matlab code of a graphics program used in our lab in Octave. Octave tells me there is no definition of the function "uicontrol", which is used in the code. After some searching, I read that the package JHandles has an implementation of the "uicontrol" GUI function. However, I can't find jhandles anywhere. Therefore: Can someone tell me how to get the jhandles package and get it running in my copy of Octave, installed in Mac OS X 10.6? OR Is there another implementation of "uicontrol" in another library/package in Octave? Thanks! Currently looking for the same thing.

What's the octave equivalent of eig(X, 'nobalance')

烂漫一生 提交于 2019-12-06 11:24:36
I'm trying to find the equilibrium distribution of a markov chain, which means finding the eigenvalues of the transition matrix representing it, however, the eig function automatically normalises the eigenvectors it returns, in MatLab there is a flag you can pass to the function to stop this behaviour eig(X, 'nobalance') Where X is a matrix. See http://www.mathworks.com/help/techdoc/ref/eig.html . However, when I try this in octave I just get an error: error: eig: wrong type argument `sq_string' Is there some other function I should be calling? Cheers If your goal is to compute the equilibrium

Error when running simple script containing local function in Octave

百般思念 提交于 2019-12-06 09:13:23
My file testtest.m looks like : pluse(1, 2) function retval = pluse(input1, input2) retval = input1 + input2; endfunction Then I get: error: 'pluse' undefined near line 1 column 1 error: called from testtest at line 1 column 1 Why do I get this error? To answer your question properly, I need to point out two things: The canonical way to create a function in both octave and matlab is by placing it in a dedicated file by the same name, and starting the file with a function declaration . The corollary of this is that any file in the path that starts with a function declaration is detected at

Octave hangs when you first use graphic functions (plot, imagesc, etc.),

你离开我真会死。 提交于 2019-12-06 07:46:31
When I first use the plotting functions (for example, plot(1,1) ), Octave hangs for a few minutes. The second and subsequent calls for the same functions are performed quite quickly. The same behavior is repeated the next time you start Octave. I used Octave 4.2.1 with both qt graphics_toolkit and gnuplot graphics_toolkit. Operating system was Windows 7 and 10. I used standart Octave Installer. How to solve this problem? This problem is quite common. See for example - Cannot use Octave 4.0.0 graphics toolkit functions or Plot doesn't work in Octave 4.0.0 But I did not find any solutions for

Installing general package in octave has error

瘦欲@ 提交于 2019-12-06 07:19:45
问题 I have error in installing general package using the instruction. pkg install -forge general and get the message octave:3> pkg install -forge general In file included from /usr/local/octave/3.8.0/lib/gcc47/gcc/x86_64-apple-darwin13/4.7.3/include/stdint.h:3:0, from /usr/local/octave/3.8.0/include/octave-3.8.0/octave/oct-conf-post.h:167, from /usr/local/octave/3.8.0/include/octave-3.8.0/octave/config.h:3351, from /usr/local/octave/3.8.0/include/octave-3.8.0/octave/../octave/oct.h:31, from SHA1

Octave: Load all files from specific directory

醉酒当歌 提交于 2019-12-06 07:06:58
I used to have Matlab and loaded all txt-files from directory "C:\folder\" into Matlab with the following code: myFolder = 'C:\folder\'; filepattern = fullfile(myFolder, '*.txt'); files = dir(filepattern); for i=1:length(files) eval(['load ' myFolder,files(i).name ' -ascii']); end If C:\folder\ contains A.txt, B.txt, C.txt, I would then have matrices A, B and C in the workspace. The code doesn't work in octave, maybe because of "fullfile"?. Anyway, with the following code I get matrices with the names C__folder_A, C__folder_B, C__folder_C. However, I need matrices called A, B, C. myFolder = 'C

Octave添加Package的问题

邮差的信 提交于 2019-12-06 06:26:45
背景 用Octave绘制高斯正太分布的时候需要用到函数normpdf(),提示需要安装statistics包。 虽然Octave可以替代Matlab,但两者之间还是有区别的。Octave默认的安装包比Matlab更小,所以某些工具以Package形式存在。当用到这些模块再自行导入。 Octave包 Octave Package :可以下载自己需要的相应包(Package)。 Octave添加Package的方式 方法一:pkg install -forge Package_Name命令在线安装 如安装io包: pkg install -forge io 方法二:本地安装 将工作目录切换到安装包所在的位置 pkg install -forge Package_name version 例如安装:statistics-1.4.1.tar.gz包时,命令如下: pkg install -forge statistics-1.4.1.tar.gz 来源: https://www.cnblogs.com/tamkery/p/11965362.html

How to manually convert Matlab GUIDE GUI code to Octave UI Components

眉间皱痕 提交于 2019-12-06 06:11:21
问题 How should I go about to convert (manually) code created by Matlab GUIDE GUI, to use Octave's UI Components? Stuff like this: gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @Mat_to_Octave_OpeningFcn, ... 'gui_OutputFcn', @Mat_to_Octave_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end etc. etc. Where can I find a comprehensive