matlab

Unit-testing framework for MATLAB

What are the unit-testing frameworks for MATLAB out there, and how do they compare? How should I choose one for our project? What are their pros and cons? ...

Performance of find() vs. for loop

I've got a large (4000 values) set of unsorted, normally distributed points. I'm taking each of these data points into bins whose limits are in the BinLimit array. Then I'm tabulating the number of values in each bin. X is the array of raw data, and N is the number of data points. The number of bins desired (TotalBins) is specified by t...

Frequency response using FFT in MATLAB

Here is the scenario: using a spectrum analyzer i have the input values and the output values. the number of samples is 32000 and the sampling rate is 2000 samples/sec, and the input is a sine wave of 50 hz, the input is current and the output is pressure in psi. How do i calculate the frequency response from this data using MATLAB, usi...

sum(Array) says index exceeds matrix dimensions

Hi, I am a newbie to Matlab .I was trying to do some image matching.Image X is bigger and Image Y is smaller.Our aim is to find all possible overlaps of y with x and then compute sum of square differences for RGB at each such overlap(ie x^2+y^2+z^2).So I find a location (i,j) in bigger image from where we pick a tile and match . To be p...

Finding Similarity measure between different images?

problem Statement : I have to make a table consists of ( i,j,s(i,j)) where i and j are Keyframes or images and S(i,j) is similarity measure value between those images. how to find similarity value between two images? Can anyone please tell me how to find this Using sum of squared distances of pixels using Matlab ? My problem cont...

Quickly cross-check complex Math Results?

I am doing matrix operations on large matrices in my C++ program. I need to verify the results that I get, I used to use WolframAlpha for the task up until now. But my inputs are very large now, and the web interface does NOT accept such large values (textfield is limited). I am looking for a better solution to quickly cross-check/do ma...

Help Required With Graph Plotting in MATLAB

I am about to present my work that I have created in MATLAB, but I am having trouble manipulating my data into a presentable form using the plot function. My code looks like this: [inputname, pathname] = uigetfile('*.wav', 'Select WAV-file'); thumb1 = inputname; %# Get filename information fprintf('\n%s is being turned i...

Making a loop efficient in Matlab code: use C or will Java do?

Hi. I want to speedup some matlab code involving a loop. A common solution is to code the loop in C and call it from matlab. However, I was wondering if I can get similar benefits from implementing the loop in Java instead - perhaps the just-in-time compilation makes it faster? ...

Getting Started with MATLAB?

How do you get started with MATLAB? Hints/Links to some must read/watch tutorials/screen-casts would be great! Update: I know C/C++/Java ...

Is it possible to show numbers in non-engineering format in Matlab?

I have some large floating point numbers such as 1243564832.75 in Matlab. Matlab changes the format to 1.2435e09 or if I use long format: 1.2435648e09 or something like that. Is there any way I can display the numbers in their non-engineering format (1243564832.75)? Thanks, Shadi. ...

(Re)starting Matlab after error from error location

Hello all, I'm debugging a matlab script that takes ~10 minutes to run. Towards the end of the script I do some i/o and simple calculations with my results, and I keep running into errors. Is there a way to start matlab from a certain sport in a script after it exits with an error--the data is still in the workspace so I could just comm...

How to customize a discrete function plot in MATLAB?

I would like to plot discrete values in MATLAB like this: stairs() and stem() make similar plots but can I configure one of them to look like the image above? ...

how to take values after a specific point and discard values before it, in MATLAB?

I have an array, let's say A = 1 2 3 4 5 6 7 8 9 2 3 4 3 4 5 1 6 8 I took a point from 3rd column, let's say p=9. Now I want a new array that gives me all values after 9 and discards values before 9. For example: ans = 7 8 9 2 3 ...

Looking for solution in Simulink

Hello! I looking for block in Simulink to make some recursion, for example: I want calculate A_(k+1) = 2 * A_(k) , where k = 1,2,3,4 and A_(1) = 3. How to make something like this ? I only find initial values in integrator :/ ...

Initialize MATLAB matrix based on indices

I'm trying to create a matrix M satisfying: M(i,j) = f(i,j) for some f. I can do elementwise initialization through say M = zeros(m,n) then looping. For example (in Octave): M = zeros(m,n) for i = 1 : m for j = 1 : n m(i, j) = (i+j)/2; endfor endfor But AFAIK loops are not the optimal way to go with MATLAB. Any hints? ...

Error using load command to open .mat file in Matlab

Here's a part of my code where I am entering a name of the .mat file, which is located in the same folder as my code. However it does not identify the file name and gives an error: "??? Error using ==> load Unable to read file 'q_5wells_yearly_CMG.mat': No such file or directory." q_MethodType=input('Do you want to use q from "CMG", ...

producing subplots to then combine them into a figure later? (matlab)

Hi, My program produces small figures during the command cycle. Is there a way to just save these figures to then combine them in one figure later? So then how do you load them into a single figure later? Best, ...

How to pass a number of java.awt.image.BufferedImage's to Matlab

Hi, I'm writing a Java application for real-time image processing. I'd like to be able to validate the algorithms used or present data I acquire in the Java app with Matlab afterwards. In the Java app I'm using java.awt.image.BufferedImage's to process data internally. The program usually runs about 1-2 minutes and grabs data at 25Hz, 1...

Converting a matrix in MATLAB

Let's say I've got a vector a = [1 2 4]. I want it converted into a vector which looks like this b = [1 2 0 4], i.e. each number is placed into a correct position and since 3 is not included into the vector a, it is replaced by 0 in vector b. This can be done the following way: a = [1 2 4] b = zeros(1, size(a, 2)); b(1, a) = a; I can'...

flip and rotate a color image in MATLAB

How do I flip a color image (RGB) in MATLAB? The fliplr does not seem to work without losing the color contents, as it only deals with 2D. As well, the imrotate may not rotate color images. ...