matlab

How do I create a string using a loop variable in MATLAB?

I have a loop like this: for i=1:no %some calculations fid = fopen('c:\\out.txt','wt'); %write something to the file fclose(fid); end I want data to be written to different files like this: for i=1, data is written to out1.txt for i=2, data is written to out2.txt for i=3, data is written to out3.txt etc. Doing 'out'+ i ...

Mathematical Programming Languages

Given my previous questions about the the usage of AMPL. Are there any other programming/scripting languages that are strictly meant for mathmatical processing? For example: Matlab (it does deviate a bit from a mathematical structure, but its close enough), Mathmatica, and AMPL ...

Remove Characters from EOF while Writing to File in Matlab

In Matlab, after creating a certain number of lines and printing them to a file, I have the need to delete a line and rewrite the rest of the data to that same file. When I do so, the new data overwrites the previous data, but since the data is shorter than the original, there are still remnants of the original data. Does anyone have a...

How to make a basic line plot in MATLAB?

I have a = 54.1848 50.0456 99.9748 83.1009 63.1457 91.7577 64.0805 48.2090 75.7711 t = 79.7077 31.0913 14.9389 10.8303 16.4844 26.8465 41.6946 77.3369 186.3246 How can make a simple line plot with a on y axis and t on x axis? plot (a,t) gives and plot (t,a) gives I don't ...

MATLAB OOP: is it slow or am I doing something wrong?

[please also read the edit below] I'm experimenting with MATLAB OOP, as a start I mimicked my C++'s Logger classes and I'm putting all my string helper functions in a String class, thinking it would be great to be able to do things like a + b, a == b, a.find( b) instead of strcat( a b), strcmp( a, b), retrieve first element of strfind(...

Basics of normalized cross correlation

I am trying to use normxcorr2 (normalized cross-correlation) from MATLAB for calculating velocity of moving shapes in a developing embryo. I have 3 questions: 1) My image size is 260x360 pixels. I give a template size of 10x10 pixels and I ask the command to search for this template in the subsequent frame in a search window of 50x50 pi...

basic on matlab

what are the differences between a MATLAB script file and a MATLAB function? ...

How do I gaussian blur an image without using any in-built gaussian functions?

I want to blur my image using the native gaussian blur formula. I read this, but I am not sure how to implement this. How do I use the formula to decide weights? [I mentioned MATLAB because I do not want to use any built in fuctions that it has] ...

How to create 3 dimensions matrix in numpy , like matlab a(:,:,:)

How to create 3 dimensions matrix in numpy , like matlab a(:,:,:) . I try to convert matlab code that create 3d matrix to python by use numpy.array and i don't know how to create 3d matrix/array in numpy ...

Detect marker in 2D image

I am hoping to obtain some some help with 2D object detection. I'll give a brief overview of the context in which this will be implemented. There will be an image taken of the ceiling. The ceiling will have markers placed on it so the orientation of the camera can be determined. The pictures will always be taken facing straight up. My ...

MATLAB: Create Delaunay Triangulation with Opening

I have a polygon with V vertices and n number of openings. How can I create a mesh using Delaunay triangulation for this polygon in MATLAB? I know I can use the delaunay function, but I don't know how to input the opening. ...

embed python in matlab mex file on os x

I'm trying to embed Python into a MATLAB mex function on OS X. I've seen references that this can be done (eg here) but I can't find any OS X specific information. So far I can successfully build an embedded Python (so my linker flags must be OK) and I can also build example mex files without any trouble and with the default options: jm...

How do I plot lines between all points in a vector in MATLAB?

I have a vector containing some points in 2-D space. I want MATLAB to plot these points with lines drawn from every point to every other point. Basically, I want a graph with all vertices connected. Can you do that with plot and if so, how? ...

Call python function from MATLAB

Hello, I need to call a python function from MATLAB. Any ideas how can I do this? ...

Matlab: avoiding memory allocation in mex

I'm trying to make my mex library avoid all memory allocation what so even. Until now, the mex got an input, created some matrices using mxCreate...() and returned this output. But now I'd like to modify this interface so that the mex itself would not do any allocations. What I had in mind is that the mexFunction will get as input the ma...

How do I solve a determinant in MATLAB?

As a simple example, let's say you have this matrix: M = [omega 1; 2 omega]; and you need to solve for the values of omega that satisfy the condition det M = 0. How do you do this in MATLAB? It is surely something simple, but I haven't found the function yet. ...

Corner Cases, Unexpected and Unusual Matlab

Over the years, reading others code, I encountered and collected some examples of MATLAB syntax which can be at first unusual and counterintuitive. Please, feel free to comment or complement this list. I verified it with r2006a. set([], 'Background:Color','red') MATLAB is very forgiving sometimes. In this case, setting properties to...

How do I create an N-D matrix of doubles in a MATLAB MEX file?

I need to make a 3-D matrix in a MEX file. In the API reference, there is mention of mxCreateCellArray for N-D cell arrays, mxCreateStructArray for structs, etc. But there is no mxCreateDoubleArray mentioned. Is this possible? ...

Computing object statistics from the second central moments

I'm currently working on writing a version of the MATLAB RegionProps function for GNU Octave. I have most of it implemented, but I'm still struggling with the implementation of a few parts. I had previously asked about the second central moments of a region. This was helpful theoretically, but I'm having trouble actually implementing ...

Find the corners of a polygon represented by a region mask

BW = poly2mask(x, y, m, n) computes a binary region of interest (ROI) mask, BW, from an ROI polygon, represented by the vectors x and y. The size of BW is m-by-n. poly2mask sets pixels in BW that are inside the polygon (X,Y) to 1 and sets pixels outside the polygon to 0. Problem: Given such a binary mask BW of a ...