matlab

How to call a function in a for loop in MATLAB?

I would like to call (execute) an m-file (function) in a loop like this: global m, r m = 2; for n = 2:10; for r1 = 0:n-m; r2 = n-m-r1; r = [r1,r2]; [Call the function here?????????] end end This is the function: function main x0 = [-0.5403,0.5471]; fsolve(@fcn,x0) function z = fcn(X) rand('twister',5409); ...

FFT in MATLAB ( I need help)

Could anybody please tell me whether I can perform this integration with FFT in MATLAB? How? Please answer as soon as possible with the details. Suppose there exists 2 rectangular planes, say, input accessed by x1 and y1 variables and the resulting plane is output accessed by tetax and tetay variables. This is the integral in pseudo-co...

Drawing a triangle in an image in MATLAB

I need to draw a triangle in an image I have loaded. The triangle should look like this: 1 0 0 0 0 0 1 1 0 0 0 0 1 1 1 0 0 0 1 1 1 1 0 0 1 1 1 1 1 0 1 1 1 1 1 1 But the main problem I have is that I do not know how I can create a matrix like that. ...

Compiling MATLAB 2009b applications to Windows Executables

Does anyone know how to add full (n.n.n.n) Windows file version information to COM dlls and .Net Assemblies compiled from MATLAB? The resulting dlls do not seem to contain a VersionInfo structure and so utilities like Resource Hacker don't work. ...

How can I solve an ODE without using nested functions?

I have some differential equations that I need to solve using MATLAB's ODE solvers. While the differential equations themselves are fairly simple, they depend on a lot of "constants". These constants aren't universal, and need to be supplied by the caller. An example ODE of this sort would be: dx/dt = -j * (k + x) ./ (l + x) Where j,...

Is it possible for a MATLAB script to behave differently depending on the OS it is being executed on?

I run MATLAB on both Linux and Windows XP. My files are synced among all of the computers I use, but because of the differences in directory structure between Linux and Windows I have to have separate import and export lines for the different operating systems. At the moment I just comment out the line for the wrong OS, but I am wonderin...

Algorithm for best-effort classification of vector

Given four binary vectors which represent "classes": [1,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,1] [0,1,1,1,1,1,1,1,1,0] [0,1,0,0,0,0,0,0,0,0] What methods are available for classifying a vector of floating point values into one of these "classes"? Basic rounding works in most cases: round([0.8,0,0,0,0.3,0,0.1,0,0,0]) = [1 0 0 0 0 0 0...

matlab in C C++ and C C++ in matlab

It seems that are several ways to call matlab in C C++ and to call C C++ in matlab. While I try to list them here, please point it out If I miss something. To call C C++ in matlab, there are also two methods. The first one is to call functions in C shared libraries. The second one is to build C C++ code into binary MEX-files, which will...

How do I color part of a graph under a line in MATLAB?

I would like to have in the same figure a line plot and a part of the graph under the line colored (a confidence interval). How can I do this in MATLAB? I already tried the following, but it doesn't work (it only shows the area): plot(theta, p_prior_cum) area(theta(50:70), p_prior_cum(50:70)) axis([0 1 0 1]) ...

How to apply a patch

I have this patch code which i downloaded from a web article (Calling Matlab from Java). http://www.cs.virginia.edu/~whitehouse/matlab/JavaMatlab.html But I donot know how to apply it in my windowsXp running computer. What I'm trying to do is call Matlab script file from java. I have found the necessary source codes and every thing but...

WCF Between Matlab & a C# application.

Hi, I am trying to communicate between 2 applications. 1 matlab application 1 C# written application. The C# application publishes its functions with the Microsoft WSDL application that is non-standard and matlab cannot understand it. Do you know of any solutions to this problem? Some application that does publish the WCF functions in ...

How do I convert a large array of 8 bit binary values in MATLAB?

This is a follow-up question to another SO question of mine. I have a large array of 8 bit binary values that I want to convert back to uint8. I have used Amro's lookupTable solution from the previous question. Now I want to do the reverse. I wanted to do a lookup table but sadly I am unable to. What I managed to do is the following: ...

How do I plot confidence intervals in MATLAB?

I want to plot some confidence interval graphs in MATLAB but I don't have any idea at all how to do it. I have the data in a .xls file. Can someone give me a hint, or does anyone know commands for plotting CIs? ...

Call C++ code from MATLAB?

I have some code which I need to code in C++ due to heavy reliance on templates. I want to call this code from MATLAB: basically, I need to pass some parameters to the C++ code, and have the C++ code return a matrix to MATLAB. I have heard this is possible with something called a MEX file which I am still looking into. However I am not s...

How do I add the MathWorks logo to an image in MATLAB?

I had asked in a previous question about how to reproduce an image in MATLAB. Now, I want to modify that image by removing the word "Math" and replacing it with the MathWorks logo. I'm having trouble figuring out how to add the logo to the figure and adjust its position. Here's the code I have been trying to use to add the logo to the ...

MATLAB- passing a function handle parameter into another function as a handle

Working on an assignment involving Genetic Algorithms (loads of headaches, loads of fun). I need to be able to test differing crossover methods and differing mutation methods, to compare their results (part of the paper I have to write for the course). As such, I want to just pass the function names into the Repopulate method, as functio...

Running MATLAB function from Java

I have an .m file in MATLAB which I would like to call from Java an get the solution as a string or whatever in Java. This sounds really simple but for some reason I can't make it work. I tried this: matlab -nosplash -wait -nodesktop -r myFunction but I'm not sure how I parse the answer since MATLAB opens it's own command line (in W...

Purposefully Slow MATLAB Function?

I want to write a really, really, slow program for MATLAB. I'm talking like, O(2^n) or worse. It has to finish, and it has to be deterministically slow, so no "if rand() = 123,123, exit!" This sounds crazy, but it's actually for a distributed systems test. I need to create a .m file, compile it (with MCC), and then run it on my distribut...

MATLAB: Why is this summation not working properly?

I'm trying to perform a really simple summation in MATLAB. Here is my code: moment = 0; for y=1:rows, for x=1:cols, moment = moment + (x^p * y^q * Im(y,x)); end end I want (x^p * y^q * Im(y,x)) to be calculated for each iteration and added to the moment variable, but this function is returning the moment the first tim...

MATLAB: What's [Y,I]=max(AS,[],2);?

I just started matlab and need to finish this program really fast, so I don't have time to go through all the tutorials. can someone familiar with it please explain what the following statement is doing. [Y,I]=max(AS,[],2); The [] between AS and 2 is what's mostly confusing me. And is the max value getting assigned to both Y and I ? ...