octave

setting multiple fields at once / add new field to a cell struct

☆樱花仙子☆ 提交于 2020-01-24 11:54:27
问题 I have a 1xn struct. The structs contains some fields with numeric cells. Not every struct has the same fields. So I would like to add the missing fields to the struct. But I didn't get it. % Mimimal example % I have same cells, imported from csv by csv2cell() clear dataCell{1}={"field_a","field_b","field_c"; ... 1,2,3; ... 4,5,6}; dataCell{2}={"field_a","field_b","field_d"; ... 1,2,4; ... 4,5,8}; % Then I convert them to a struct for ii=1:numel(dataCell) DataStruct{ii}=cell2struct((dataCell

setting multiple fields at once / add new field to a cell struct

ε祈祈猫儿з 提交于 2020-01-24 11:53:29
问题 I have a 1xn struct. The structs contains some fields with numeric cells. Not every struct has the same fields. So I would like to add the missing fields to the struct. But I didn't get it. % Mimimal example % I have same cells, imported from csv by csv2cell() clear dataCell{1}={"field_a","field_b","field_c"; ... 1,2,3; ... 4,5,6}; dataCell{2}={"field_a","field_b","field_d"; ... 1,2,4; ... 4,5,8}; % Then I convert them to a struct for ii=1:numel(dataCell) DataStruct{ii}=cell2struct((dataCell

parallel computing in octave

只愿长相守 提交于 2020-01-24 06:14:06
问题 I found some sources online that indicate that there are tools for Octave that allow one to parallelize algorithms, but couldn't find any details or how to get and use them. Any help/insight into this would be great. 回答1: http://octave.sourceforge.net/parallel/ Just install the package and the function reference may help. 来源: https://stackoverflow.com/questions/7047840/parallel-computing-in-octave

Any reason why Octave, R, Numpy and LAPACK yield different SVD results on the same matrix?

佐手、 提交于 2020-01-22 18:38:10
问题 I'm using Octave and R to compute SVD using a simple matrix and getting two different answers! The code is listed below: R > a<-matrix(c(1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1), 9, 4) > a [,1] [,2] [,3] [,4] [1,] 1 1 0 0 [2,] 1 1 0 0 [3,] 1 1 0 0 [4,] 1 0 1 0 [5,] 1 0 1 0 [6,] 1 0 1 0 [7,] 1 0 0 1 [8,] 1 0 0 1 [9,] 1 0 0 1 > a.svd <- svd(a) > a.svd$d [1] 3.464102e+00 1.732051e+00 1.732051e+00 1.922963e-16 > a.svd$u [,1] [,2] [,3] [,4] [1,] -0.3333333 0.4714045

MATLAB repeat numbers based on a vector of lengths

[亡魂溺海] 提交于 2020-01-22 11:14:25
问题 Is there a vectorised way to do the following? (shown by an example): input_lengths = [ 1 1 1 4 3 2 1 ] result = [ 1 2 3 4 4 4 4 5 5 5 6 6 7 ] I have spaced out the input_lengths so it is easy to understand how the result is obtained The resultant vector is of length: sum(lengths) . I currently calculate result using the following loop: result = ones(1, sum(input_lengths )); counter = 1; for i = 1:length(input_lengths) start_index = counter; end_index = counter + input_lengths (i) - 1; result

Splitting a DTMF signal from a wav file using Matlab

别等时光非礼了梦想. 提交于 2020-01-21 09:53:47
问题 Here is the context of the problem: I have a DTMF signal in wav format, I have to identify the number sequence it has encoded. I must do so using fast fourier transform in Matlab, implying that I read the wav file using wavread and to identify each number that is seperated by 40ms silence or more. Here is my code so far: [signal, fs] = wavread( 'C:\Temp\file.wav' ); % here, fs = 8000Hz N = 512; T = 1/fs; L = length( signal ) samples = fs / 1000 * 40 windows = floor(L / samples) t = (1:L)/fs;

How to compute only the diagonal of a matrix product in Octave?

我怕爱的太早我们不能终老 提交于 2020-01-20 01:47:05
问题 Is there a way in Octave to compute and store only the diagonal of a matrix product? Basically like doing: vector = diag(A*B); I don't care about any of the values of A*B except those on the diagonal. The matrix sizes are around 80k x 12 and 12 x 80k , so even if I didn't care about the speed/extra memory it simply wont fit in RAM. Strange, since Octave is a package for huge data sets and diagonals are very important, so it should be possible. 回答1: The first element in the diagonal is the

Octave make command fails with “Cannot open file debug.h”

别说谁变了你拦得住时间么 提交于 2020-01-17 08:04:46
问题 I have tried to compile Octave 3.4.3 on Kubuntu 10.04 LTS on an AMD64 machine but make fails with the following error /bin/bash ../libtool --tag=F77 --mode=compile f77 -O -c -o arpack/src/libcruft_la-cgetv0.lo `test -f 'arpack/src/cgetv0.f' || echo './'`arpack/src/cgetv0.f libtool: compile: f77 -O -c arpack/src/cgetv0.f -fPIC -o arpack/src/.libs/libcruft_la-cgetv0.o cgetv0: Cannot open file debug.h /usr/bin/f77: aborting compilation make[2]: *** [arpack/src/libcruft_la-cgetv0.lo] Error 1 make

Octave failing to include parts of a plot when saved to file

点点圈 提交于 2020-01-17 05:53:08
问题 I have a very basic custom boxplot function: function myboxplot(LPercentile, Median, RPercentile, Height, LineWidth, BoxHeight, MarkerColour, MarkerSize) hold on plot([LPercentile, RPercentile], [Height, Height], 'linewidth', LineWidth, 'color', 'k', 'linestyle', '-'); plot([LPercentile, LPercentile], [Height - BoxHeight/2, Height + BoxHeight/2], 'linewidth', LineWidth, 'color', 'k', 'linestyle', '-'); plot([RPercentile, RPercentile], [Height - BoxHeight/2, Height + BoxHeight/2], 'linewidth',

Getting the period from irregularly-spaced time series using OCTAVE

自古美人都是妖i 提交于 2020-01-17 04:14:10
问题 I have a two column array of data. First column is time (date in decimal years) and second column is the signal strength. The plot is a triangle wave or should be ideally because the sampling is irregularly timed. I've tried numerous methods to get the period of the wave, including fitting a sine wave to the data via lsqcurvefit, but it doesn't always return the right period. Using OCTAVE how do I get the period (my main aim) of this/any irregularly-spaced time series?See plot 回答1: Found