octave

How to use parallel 'for' loop in Octave or Scilab?

我只是一个虾纸丫 提交于 2019-12-18 05:56:01
问题 I have two for loops running in my Matlab code. The inner loop is parallelized using Matlabpool in 12 processors (which is maximum Matlab allows in a single machine). I dont have Distributed computing license. Please help me how to do it using Octave or Scilab. I just want to parallelize 'for' loop ONLY. There are some broken links given while I searched for it in google. 回答1: parfor is not really implemented in octave yet. The keyword is accepted, but is a mere synonym of for (http://octave

Three dimensional (3D) matrix interpolation in Matlab

大兔子大兔子 提交于 2019-12-18 03:49:25
问题 I have a 3D matrix in Matlab of certain size, however I would need to interpolate it to obtain matrix of larger size. size(M) ans= 50 108 86 I need that matrix to be interpolated and finally obtain a matrix of size 100x213x140 . Any ideas of how to do it using interp3 ? Is this possible at all? I've tried Vq = interp3(M,1:100,1:213,1:140) Error using griddedInterpolant/subsref The input data has inconsistent size. Error in interp3 (line 178) Vq = F(Xq,Yq,Zq); If I use meshgrid : [X,Y,Z] =

How to directly pass multiple outputs of a function to another?

☆樱花仙子☆ 提交于 2019-12-17 21:35:56
问题 Let me elaborate with examples: We know how to easily combine functions with a single output: a = sin(sqrt(8)); Now consider this example code containing two steps to calculate R , with X and Y as intermediate outputs. [X, Y] = meshgrid(-2:2, -2:2); [~, R] = cart2pol(X, Y); In general is there a way to combine the two functions and get rid of intermediate outputs? For instance how can I write something similar to [~, R] = cart2pol(meshgrid(-2:2, -2:2)) that works same as the previous code?

MATLAB/octave count number of operations (flops)

此生再无相见时 提交于 2019-12-17 21:35:19
问题 Is it possible to report number of operations to evaluate for example matrix/matrix (dense or sparse) in MATLAB or octave. 回答1: Haven't tried it personally, but the Lightspeed Matlab Toolbox claims to support flops counting. Apparently the flops command was a valid option in MATLAB up through version 5. 回答2: Not exactly what you're looking for, but you can use profile to get the cpu time for an operation. 来源: https://stackoverflow.com/questions/2868429/matlab-octave-count-number-of-operations

cocktail party algorithm SVD implementation … in one line of code?

半城伤御伤魂 提交于 2019-12-17 21:24:07
问题 In a slide within the introductory lecture on machine learning by Stanford's Andrew Ng at Coursera, he gives the following one line Octave solution to the cocktail party problem given the audio sources are recorded by two spatially separated microphones: [W,s,v]=svd((repmat(sum(x.*x,1),size(x,1),1).*x)*x'); At the bottom of the slide is "source: Sam Roweis, Yair Weiss, Eero Simoncelli" and at the bottom of an earlier slide is "Audio clips courtesy of Te-Won Lee". In the video, Professor Ng

Generalization of mat2str to cell arrays

眉间皱痕 提交于 2019-12-17 16:46:08
问题 I sometimes miss a function to produce a string representation of a (possibly nested) cell array. It would be a generalization of mat2str, which only works for non-cell arrays (of numeric, char or logical type). Given an array x , how to obtain a string representation y , such that evaluating this string produces x ? For example, the input x = {[10 20], {'abc'; false; true;}}; should produce an output string like y = '{[10 20], {''abc''; false; true}}'; (or some variation regarding spacing an

Getting octave to plot when invoking a function from the command line

谁都会走 提交于 2019-12-17 16:36:20
问题 I am trying to run a function in octave from the command line. The function is currently run like so: octave --silent --persist --eval 'function(input arguments)' function.m contains a plot command. When I invoke octave with the above command line parameters, the plot does show but octave enters into its interactive mode. My question is: Is there any way to get octave to display the plot without entering the interactive mode when it is invoked from the command line? 回答1: AFAIK, the plot

How can I hot one encode in Matlab? [duplicate]

回眸只為那壹抹淺笑 提交于 2019-12-17 16:11:33
问题 This question already has answers here : Create a zero-filled 2D array with ones at positions indexed by a vector (4 answers) Closed 2 years ago . Often you are given a vector of integer values representing your labels (aka classes), for example [2; 1; 3; 3; 2] and you would like to hot one encode this vector, such that each value is represented by a 1 in the column indicated by the value in each row of the labels vector, for example [0 1 0; 1 0 0; 0 0 1; 0 0 1; 0 1 0] 回答1: For speed and

Efficient multiplication of very large matrices in MATLAB

本小妞迷上赌 提交于 2019-12-17 16:08:09
问题 I don't have enough memory to simply create a diagonal D-by-D matrix, since D is large. I keep getting an 'out of memory' error. Instead of performing M x D x D operations in the first multiplication, I do M x D operations, but still my code takes ages to run. Can anybody find a more effective way to perform the multiplication A'*B*A ? Here's what I've attempted so far: D=20000 M=25 A = floor(rand(D,M)*10); B = floor(rand(1,D)*10); for i=1:D for j=1:M result(i,j) = A(i,j) * B(1,j); end end

Plot window not responding

一曲冷凌霜 提交于 2019-12-17 15:14:03
问题 I'm using Windows 7 64 bit. Each time, I'm using plot function, plot windows will shows and draws successfully, but after that it stops responding and must shut down it. For example : x = linspace(0,1,10) y = x.^2 plot(x,y); Strangely, when plot windows freeze and I must close octave windows, they will be unresponsive too. This will not happen if I don't use plot function. I don't know why. Does it because I'm using 64 bit version? Please tell me how to fix this. 回答1: The problem is likely to