matlab

How to access fields in a struct imported from a .mat file using loadmat in Python?

Following this question which asks (and answers) how to read .mat files that were created in Matlab using Scipy, I want to know how to access the fields in the imported structs. I have a file in Matlab from which I can import a struct: >> load bla % imports a struct called G >> G G = Inp: [40x40x2016 uint8] Tgt: [8...

Matlab: Return Unique Element with a Tolerance

In Matlab, there is this unique command that returns thew unique rows in an array. This is a very handy command. But the problem is that I can't assign tolerance to it-- in double precision, we always have to compare two elements within a precision. Is there a built-in command that returns unique elements, within a certain tolerance? ...

How do I pass a string as a function argument in MATLAB?

Basically, I have 10 data files and I wrote a MATLAB function to process these data. The code is like this: function Z = fitdata(file_path) A = importdata(file_path,','); ... end Since I don't want to input the same command 10 times (for different file names), I wrote another script to automate this processing. The code looks li...

Matlab book on geometry and image processing

Hi everyone, Does anyone know an easy to understand geometry and image processing book that has source code in matlab? Thanks alot! ...

Connect to Matlab engine from C in Linux

I'm trying to call the Matlab engine programatically from a C program on Linux (Matlab r2009a, Ubuntu 9.10). I've got my own code (which works in Windows), but for now I'm just trying to get the Matlab "engdemo.c" program to work on Linux. I have managed to compile & link it (after including about 15 -l<lib> switches on the gcc command ...

How to use circshift in Matlab? What am I doing wrong?

Dear developers, I would like to plot the "greasy" test signal in Matlab, and then plot a Gauss function in the same plot. The script below does that. But I would like to be able to place the Gauss function at a certain position, so I see that others often use CIRCSHIFT to move plots. When I use it I can move the Gauss function to the...

How do I make a function from a symbolic expression in MATLAB?

How can I make a function from a symbolic expression? For example, I have the following: syms beta n1,n2,m,aa= Constants u = sqrt(n2-beta^2); w = sqrt(beta^2-n1); a = tan(u)/w+tanh(w)/u; b = tanh(u)/w; f = (a+b)*cos(aa*u+m*pi)+a-b*sin(aa*u+m*pi); %# The main expression If I want to use f in a special program to find its zeroes, how c...

Cross product function in matlab

Hi all, Can someone explain to me how to use the cross product function in matlab? An example, I have the following image with 6 fixed points on the cube, how to find the two other points of the cube? ...

Error when calling compiled m-file(.jar) in a multi threaded Java app

Hi, I have a simple m-file function [fRate,Height,Width] = media(filename) obj = mmreader(filename); fRate = obj.FrameRate; Width = obj.Width; Height = obj.Height; end Which I have successfully compiled using MATLAB Builder JA into a .jar file. I have tested the .jar file in a single threaded application and it work with ...

How to call Matlab functions from linux command line ?

Basically I have a m file which looks like function Z=myfunc() % do some calculations dlmwrite('result.out',Z,','); end What I want is just execute it from command line without getting into Matlab. I tried several options (-nodisplay -nodesktop -nojvm -r ....), none of them worked. I end up getting into Matlab and have to type "qui...

How can MATLAB function wavread() be implemented in C++?

How do I implement the MATLAB function wavread in C++? It means read a WAV file into a vector array. ...

How to find the most dense regions in an image

Consider a black and white image like this http://img13.imageshack.us/img13/7401/10416827.jpg What I am trying to do is to find the region where the white points are most dense. In this case there are 20-21 such dense regions. (i.e the clusters of points makes a dense region) Can anyone give me any hint on how this can be achieved ? ...

Can't limit scope of variables in Matlab

Can anyone get the function and class scoping feature to work, as documented in Scoping Classes with Packages ? I create a directory C:\Windows\Temp+undergrad I put a file foo.m in there tat defines a function foo. I make sure C:\Windows\Temp is on the matlab path In matlab, type 'what undergrad' should result in a list of functions an...

Matlab Unused input notation details

Matlab R2009b introduced a new "operator" - ~ - to symbolize an unused function output or input. I have detailed question about that implementation. (Calling all @Loren s.) What does the function see for the value of an unused input parameter? i.e. if my function is defined as myfunc(argOne, argTwo, argThree) and it’s called like...

Saving settings in matlab

A dumb question really ... but lately I've been working on some project all day long, and my eyes are hurting. How can one save settings (color settings to be exact) in matlab, so one can reload them / interchange them for different ones when day goes and night comes ? A subquestion - where exactly does matlab (2008b in this case, I thi...

Rename image file name in matlab

Hi I Load 10,000 image files from internet site and i save it in the folder to use it in my project (image retrieval system ), now i need to rename image file in a sequential name like (image1,image2,image3,....image10000) , any one can help me... I would like to inform you that I used matlab in my work thank ...

Matlab - Speeding up a Nested For Loop

A simple question, but I'm not so great with MATLAB. I have vectors x, (n x 1) y, (m x 1) and w = [x;y]. I want to define M (n+m x 1) as M(i) = number of elements of x that are less than or equal to w(i) (w is sorted). This just isn't cutting it: N = n + m; M = zeros(N,1); for i = 1:N for j = 1:n if x(j) <= w(i) M(i) = M(i) ...

finding the best trade-off point on a curve

Say I had some data, for which I want to fit a parametrized model over it. My goal is to find the best value for this model parameter. I'm doing model selection using a AIC/BIC/MDL type of criterion which rewards models with low error but also penalizes models with high complexity (we're seeking the simplest yet most convincing explanat...

Linewidth and precision of ezplot

how is possible to determine "linewidth" and "precision" in ezplot? from "precision", i mean that if in [1 2] interval ezplot is very pale in some locations or discontinues too, when using interval[1.5 2] to ezplot, discontinuity is removed and line is continues. ...

Line of best fit scatter plot

Hi, I'm trying to do a scatter plot with a line of best fit in matlab, I can get a scatter plot using either scatter(x1,x2) or scatterplot(x1,x2) but the basic fitting option is shadowed out and lsline returns the error 'No allowed line types found. Nothing done' Any help would be great, Thanks, Jon. ...