matlab

How do I set a surf to one color (no gradient) in my matlab-plot?

My dataset consists of three vectors (x,y and z). I plot these values as dots in a 3d-plot with plot3(x,y,z), which is fine. I also want to show a plane in the same plot. To get the data of this plot I use linear regression on x and y to get a new z. This is how it looks: I want the surf to be filled with only one color (say light ...

Looking for ODE integrator/solver with a relaxed attitude to derivative precision

I have a system of (first order) ODEs with fairly expensive to compute derivatives. However, the derivatives can be computed considerably cheaper to within given error bounds, either because the derivatives are computed from a convergent series and bounds can be placed on the maximum contribution from dropped terms, or through use of pr...

How to obtain the mirror image of an array (MATLAB)?

Problem: array1 = [1 2 3]; must be converted in array1MirrorImage = [3 2 1]; So far I obtained the ugly solution below: array1MirrorImage = padarray(array1, [0 length(array)], 'symmetric','pre'); array1MirrorImage = array1MirrorImage(1:length(array1)); There must be a prettier solution to this. Anyone knows one? ...

Performance of swapping two elements in MATLAB

Purely as an experiment, I'm writing sort functions in MATLAB then running these through the MATLAB profiler. The aspect I find most perplexing is to do with swapping elements. I've found that the "official" way of swapping two elements in a matrix self.Data([i1, i2]) = self.Data([i2, i1]) runs much slower than doing it in four lines...

Separation of singing voice from music

I want to know how to perform "spectral change detection" for the classification of vocal & non-vocal segments of a song. We need to find the spectral changes from a spectrogram. Any elaborate information about this, particularly involving MATLAB? ...

Passing a million numbers from java to matlab?

I have a bit of code which runs in 10.919 s. Profiling it shows that 10.182 s are wasted in opaque.double Which is called when I use jClass.GetArrays(jArray1,jArray2); struct.prop1 = double(jArray1); struct.prop2 = double(jArray1); What can be done? I have to use Java to interact with external API. EDIT: I used the following hac...

Is there a way to call a subfunction while in cell mode in matlab?

Say I had the following code: % Cellmode_subfunction_test.m %% Cell 1 foo(1); %% Cell 2 foo(2); %% Definition of the foo subfunction function foo(num) disp(['num=' num2str(num)]); How can test cell 1 and cell 2 with the subfunction defined at the end? Edit: Basically each of the cells in this example perform some lengthy calculatio...

How to plot large data vectors accurately at all zoom levels in real time?

I have large data sets (10 Hz data, so 864k points per 24 Hours) which I need to plot in real time. The idea is the user can zoom and pan into highly detailed scatter plots. The data is not very continuous and there are spikes. Since the data set is so large, I can't plot every point each time the plot refreshes. But I also can't jus...

How to add "help"-text to a mex-function?

I am writing a Matlab mex-file. However, mex-files seem to have a serious limitation: help mexfilename won't cause a help text to appear. I could circumvent this by writing a m-file, that ultimately calls the mex-file, but includes help, but there has to be a better way. On the other side, that way I could do all the error-checking in ...

Regular expressions with matching brackets

I'm trying to extract specific hard coded variables from C source code. My remaining problem is that I'd like to parse array initialisation, for example: #define SOMEVAR { {T_X, {1, 2}}, {T_Y, {3, 4}} } It's enough to parse this example into "{T_X, {1, 2}}" and "{T_Y, {3, 4}}", since it's then possible to recurse to get the full struc...

How can I add a picture into a placeholder using PowerPoint 2003 VBA?

I am trying to create PowerPoint slides using MATLAB. It seems like it is basically the same as using VBA to create PowerPoint slides, except with slightly different syntax. The function and variable names are all the same. Anyway....I can add a picture to a slide. I can also add a specific layout, which creates some placeholders. But I...

How do I connect a curve of fixed length between two points in space using Matlab?

We have two points (x1,y1,z1) and (x2,y2,z2) in 3d space. We have a curve of fixed length which is to be connected (not with a straight line) between these points. How to proceed with the code in Matlab? ...

Equation of a helix parametrized by arc length between two points in space

What is the equation of a helix parametrized by arc length (i.e. a function of arc length) between any two points in space? Is there any function for this ? How do i implement the same using matlab or mathematica ? ...

How to execute multiple statements in a Matlab anonymous function?

I'd like to do something like this: >> foo = @() functionCall1() functionCall2() so that when I said >> foo() it would execute functionCall1() and then execute functionCall2(). (I feel that I need something like the C , operator) EDIT: functionCall1 and functionCall2 are not necessarily functions that return values. ...

How to load a c++ dll file into Matlab

I have a C++ dll file that uses a lot of other c++ librarys (IPP, Opencv +++) that I need to load into matlab. How can I do this? I have tried loadlibrary and mex. The load library does not work. The mex finds the linux things (platform independent library) and tries to include them. And that does not work. Does anyone have any good i...

Can I force two components in a three-way linear regression to be positive?

Hello, I'm sorry if I'm not using the correct mathemathical terms, but I hope you'll understand what I'm trying to accomplish. My problem: I'm using linear regression (currently least squares method) on the values from two vectors x and y against the result z. This is to be done in matlab, and I'm using the \-operator to perform the reg...

Dependency injection with no framework.

I'm writing a mid-sized analysis program (5-10kloc) in MATLAB (not my decision), and I'm trying to use dependency injection to make my code more testable. I think I understand the basic object/constructor injection model, but I'm confused as to how this scales up the dependency graph. For instance, if I have object A, which has-a objec...

free matlab environment

Hi, I'm learning the Matlab language and would like to have some kind of free environment to experiment with. The Matlab environment provided by MathWorks is commercial - there appears to be a trial available, but I can't figure out how to get the trial license. For the moment, all I need is a command-line and the "standard libraries"....

Can someone explain this example of deleting elements from a matrix in MATLAB?

The following example appears in the MATLAB tutorial: X = [16 2 13; 5 11 8; 9 7 12; 4 14 1] Using a single subscript deletes a single element, or sequence of elements, and reshapes the remaining elements into a row vector. So: X(2:2:10) = [] results in: X = [16 9 2 7 13 12 1] Mysteriously, the entire 2nd ro...

How do you write to a buffer then to a file

I'm trying to write some STL data out of matlab and I'm trying to do this by writing a MEX File (a matlab DLL written in C) At the moment I have a loop just going through my data writing out the stl syntax with the floats. ... for(m=0;m<colLen;m++) { res = m % 3; if(res == 0) { fprintf(fp, "\tfacet normal %f %f ...