matlab

How do I resize a matrix in MATLAB?

Suppose I had a 1-by-12 matrix and I wanted to resize it to a 4-by-3 matrix. How could I do this? My current solution is kind of ugly: for n=1:length(mat)/3 out(n,1:3) = mat((n-1)*3+1:(n-1)*3+3); end Is there a better way to do this? ...

How do I get results from Matlab in Java?

I can call a .m file in Matlab from Java and that works fine, but I want to retrieve the results from Matlab and display them in Java. How can I do this? ...

Default Arguments in Matlab

Hello. Is it possible to have default arguments in Matlab? For instance, here: function wave(a,b,n,k,T,f,flag,fTrue=inline('0')) I would like to have the true solution be an optional argument to the wave function. If it is possible, can anyone demonstrate the proper way to do this? Currently, I am trying what I posted above and I ...

How can I create a piecewise inline function in MATLAB?

I have a function in MATLAB which takes another function as an argument. I would like to somehow define a piecewise inline function that can be passed in. Is this somehow possible in MATLAB? Edit: The function I would like to represent is: f(x) = { 1.0, 0.0 <= x <= 0.5, -1.0, 0.5 < x <= 1.0 where 0.0 <= x <= 1.0 ...

function handle in MATLAB

Can somebody explain me the meaning of the @ (function handle) operator and why to use it? ...

How to magnify/stretch a texture with Matlab Psychtoolbox (OpenGL)?

Update: This only seems to be a problem at some computers. The normal, intuitive code seems to work fine one my home computer, but the computer at work has trouble. Home computer: (no problems) Windows XP Professional SP3 AMD Athlon 64 X2 3800+ Dual Core 2.0 GHz NVIDIA GeForce 7800 GT 2 GB RAM Work computer: (this question applies t...

Constant Latitude Line in Matlab

I'm new to mapping and would like to plot a line of constant latitude at -68 with longitude extending from -80 to -65. If I use linem or plotm with the four coordinates I just get a single point. The only way I can kind of create a fake lat line is to use a track2 great circle. But this line is not rounded the way a true latitude line wo...

need for tool for video processing

Hi I have a 2giga mpeg file of people runnig,jogging,walking etc. in it. I will use it in a image classification project but I need to segmentate the video depending on per person an per action. for example; there are 25 people in video which repeat these actions in order 1st person -runs -walks 2nd person -runs -walks and goes on....

How can I read binary image file using Core Graphics?

I created an image in Matlab and changed it into binary image file. I want to read in the file using Core Graphics APIs. Thanks ...

retrieve matlab result in java

Hi I use matlab in my project and I want to retrieve the result of matlab in java. Just I want the result. I want to retrive result of file that I make it in matlab in the java. I use this code but it give me the result in matlab windo and I want only to retrive the result in java only. this is the code public class matlab { priva...

How to create a buffer matrix in MATLAB for continuous measurements?

I'm starting programming in MATLAB and I have some problems creating a buffer matrix. I'm trying to do the following: I'm continuously obtaining an image from a webcam and after segmentation I obtain the centroid of a moving target. I need to store the centroid data for processing but I don't want it to occupy too much memory. For examp...

After learning C should I consider learning Matlab if my emphasis is on Engineering?

I hear it's the future of engineering, but I'm not entirely sold. What advantages does Matlab provide? Are there any downsides? ...

Neural network XOR backpropagation info needed.

Does anyone know where I can find some sample codes about the NN Back propagation for XOR, that I can also test the system after it was trained? Preferably in C++ or MATLAB. ...

How can I suppress MATLAB's command window when calling it from Java?

I am calling MATLAB with Java but I want to suppress the command window of MATLAB to make users feel that I use only one program which is Java. In addition I read about something called standalone executable for MATLAB, but it didn't work; will that help me? ...

Neural Net Optimize w/ Genetic Algorithm

Is a genetic algorithm the most efficient way to optimize the number of hidden nodes and the amount of training done on an artificial neural network? I am coding neural networks using the NNToolbox in Matlab. I am open to any other suggestions of optimization techniques, but I'm most familiar with GA's. ...

Turning a matlab binary matrix into a vector of the last nonzero index in a fast, vectorized fashion

Suppose, in Matlab, that I have a matrix, A, whose elements are either 0 or 1. How do I get a vector of the index of the last non-zero element of each column in a faster, vectorized way? I could do [B, I] = max(cumsum(A)); and use I, but is there a faster way? (I'm assuming cumsum would cost a bit of time even suming 0's and 1's). ...

Visualizing a neural network having custom transfer functions in MATLAB

I have constructed a Neural network in Matlab that uses my own custom functions as transfer functions. For example, I've coded a script file 'mexicanhat.m' implementing the Mexican hat function as the transfer function, with all the boilerplate code as necessary (copied from inbuilt 'tansig' function). Now, whenever I issue the Matlab'...

Elementwise ifs in matlab - do they exist?

Say I have the following basic if-statement: if (A ~= 0) % do something like divide your favorite number by A else % do something like return NaN or infinity end The problem is that A is not a simple number but a vector. Matlab returns true if no element in A is 0. What I am looking for is a vectorized? way of perforimg the if-s...

Finding an approximate local maximas with noisy data in Matlab

Hi, The matlab FAQ describes a one-line method for finding the local maximas: index = find( diff( sign( diff([0; x(:); 0]) ) ) < 0 ); But I believe this only works if the data is more or less smooth. Suppose you have data that jumps up and down in small intervals but still has some approximate local maximas. How would you go about f...

Multiple matrices in matlab without recursion

I have to write a Matlab script that does this: The input is 2 matrices, A(m x n) and D(m x 1). The output is a matrix, C (m x n). C is calculated like this: function c = scanrow(a,d) [rows columns] = size(d); for i=1:columns a(i,:) = a(i,:).*d(i); end c = a; end The requirement is not using recursion. I have no idea to solve this...