matlab

Data streaming in MATLAB with input data coming in from a C++ executable

I'm completely new to MATLAB and I want to know what my options are for data streaming from a C++ file. I heard of using the MATLAB "engine" for this purpose, and some of the methods like engPutVariable, etc., but can someone give me a thorough example of how to go about doing it? I'm trying to implement streaming a sine wave, but a sim...

What's the best MATLAB equivalent? (open source or otherwise free)

What is the best open-source (or otherwise free) MATLAB equivalent, in your opinion, and why? Something with many built-in functions relevant to engineering and science, and a variety of good graphing capabilities. Syntax close to MATLAB's is a bonus. I've invested some time getting into SciLab, but in retrospect I'm not too enthrall...

Parallel MATLAB and logging

I am running an experiment distributed over several computers using the Parallel computing toolbox. I want to be able to produce a log of the progress of the experiment (or of any error occurring) and save this info in a file while the processes are running. What is the standard way to do it? EDIT: I use embarrassingly parallel I want...

How To Get the Range of a Page Using Word Automation

How do you find the range of page n in Microsoft Word using office automation? There appears to be no getPageRange(n) function and it is unclear how they are divided. ...

Equidistant points across a cube

I need to initialize some three dimensional points, and I want them to be equally spaced throughout a cube. Are there any creative ways to do this? I am using an iterative Expectation Maximization algorithm and I want my initial vectors to "span" the space evenly. For example, suppose I have eight points that I want to space equally in...

Jump in m-file

I'm working with the m-file editor of MATLAB and I need to jump from a line to another. As long as I need to jump from inside a "For...end", I can't use the usual "while" technique. Is there anyway to jump from a line to another, like "goto" in C? Best Regards ...

AWGN generator for .NET

I'm looking for an Additive White Gaussian Noise generator for .NET. I know that somewhere there is some degree of interoperability between .NET and MATLAB, which has a AWGN generator, but I don't know if its free EDIT and I just found it. Probably other applications as GNU Octave, which have similar functionalities to MATLAB, have .NE...

Dynamically add fields to MATLAB GUI?

I'm generating a MATLAB GUI using GUIDE, but I want to create fields when a user clicks on a button. Is there any way to dynamically add new GUI objects in the callbacks? ...

Matrix from Python to MATLAB

I'm working with Python and MATLAB right now and I have a 2D array in Python that I need to write to a file and then be able to read it into MATLAB as a matrix. Any ideas on how to do this? Thanks! ...

How do you handle resources in MATLAB in an exception safe manner?

Since there is no finally clause to the try-catch block in MATLAB, I find myself writing lots of code like the following: fid = fopen(filename); if fid==-1 error('Couldn''t open file'); end try line = getl(fid); catch ME fclose(fid); rethrow ME; end fclose(fid); I find having the fclose function in two places ugly and err...

How to read text fields into MATLAB and create a single matrix

I have a huge CSV file that has a mix of numerical and text datatypes. I want to read this into a single matrix in Matlab. I'll use a simpler example here to illustrate my problem. Let's say I have this CSV file: 1,foo 2,bar I am trying to read this into MatLab using: A=fopen('filename.csv'); B=textscan(A,'%d %d', 'delimiter',',')...

Developing a binary matrix pattern

I have a binary matrix of size m-by-n. Given below is a sample binary matrix (the real matrix is much larger): 1010001 1011011 1111000 0100100 Given p = m*n, I have 2^p possible matrix configurations. I would like to get some patterns which satisfy certain rules. For example: I want not less that k cells in the jth column as zero I ...

How to use command line Matlab from .NET without linking?

I finally discovered a way to use command line Matlab from .NET without linking: Write variables from .NET to a MAT file using David A. Zier's "csmatio" dll. Read the file from Matlab, process it and save the results to a MAT file: var process = new Process() { StartInfo = new ProcessStartInfo() { FileName = MatlabExec...

How can I program a GUI in MATLAB?

I need to create a GUI in MATLAB for my project. I looked everywhere for examples of how to program a GUI but I couldn't find a lot. What are some good sites or techniques for GUI programming in MATLAB? ...

MATLAB: impoint getPosition strange behaviour

I have a question about the values returned by getPosition. Below is my code. It lets the user set 10 points on a given image: figure ,imshow(im); colorArray=['y','m','c','r','g','b','w','k','y','m','c']; pointArray = cell(1,10); % Construct boundary constraint function fcn = makeConstrainToRectFcn('impoint',get(gca,'XLim'),get(gca,'YLi...

Applying MATLAB's idwt2 several times

I am using MATLAB to apply the Discrete Wavelet Transform on an image. I am applying it several times (3) in order to get a 3 level transform. I am using the dwt2 function provided by MATLAB in order to compress and idwt2 to make the decompression. The problem is that I do not know how to decompress several times, as in apply idwt2 sever...

MATLAB: collect from array of structs

The output of eg >>w = whos; returns an array of structs. I would like to construct an array whose elements are the scalars from a particular field name in each struct. The most obvious way of doing this doesn't return an array as I want, but each answer separately. >> w(1:2).bytes ans = 64 ans = 128 I could do it with a loop...

Determine location of a java class loaded by Matlab

When using java from Matlab, is there some way to figure out from where in matlab's java class path is a class being loaded? I'm trying to diagnose a error caused by conflicting versions of the same class being used simultaneously. Specifically, the class I'm looking for is org.apache.lucene.store.FSDirectory. It seems to be used by one...

MATLAB converting a vector of values to uint32

I have a vector containing the values 0, 1, 2 and 3. What I want to do is take the lower two bits from each set of 16 elements drawn from this vector and append them all together to get one uint32. Anyone know an easy way to do this? Follow-up: What if the number of elements in the vector isn't an integer multiple of 16? ...

Variable length MATLAB arguments read from variable

I have a function with variable arguments, declared in the standard way: [] = foo ( varargin ) and I would like to call it from another function, but specify the arguments programmatically. My best attempt is something like the following: % bar isn't populated like this, but this is how it ends up bar = { 'var1' 'var2' 'var3' }; foo...