matlab

How do I delete the intersection of sets A and B from A without sorting in MATLAB?

Two matrices, A and B: A = [1 2 3 9 7 5 4 9 4 1 4 7] B = [1 2 3 1 4 7] All rows of matrix B are members of matrix A. I wish to delete the common rows of A and B from A without sorting. I have tried setdiff() but this sorts the output. For my particular problem (atomic coordinates in protein structures) maintaini...

How can I move variables into and out of a structure akin to LOAD and SAVE in MATLAB?

Is there a quick way (i.e. one line) to dump a collection of variables "in" a structure, using the variable names as the structure fields? The "load" function basically does this but saving and loading to a temporary file seems ugly. For example: clear a = 'adsf' b = rand(10); x = var2struct(a,b) x.a x.b or better yet: x = var2str...

Failed to write stream data, matlab

hi I have writtring a script that convert a set of BMPs to avi. up until recently it worked fine. now I get this wierd error "Failed to write stream data". I get it after converting 5 libraries of bmps to avi. It runs over librarirs of BMPs and convert each library to avi. each time it stacks in the 6th movie.. there are no corrupts fil...

Cox regression in MATLAB

I know there is COXPHFIT function in MATLAB to do Cox regression, but I have problems understanding how to apply it. 1) How to compare two groups of samples with survival data in days (survdays), censoring (cens) and some predictor value (x)? The groups defined by groups logical variable. Groups have different number of samples. 2) Wh...

Neural Network for multidimensional problem

Hi there, I'm wondering if it's possible for Neural Network to operate on matrices say I want to: A(i)=matrix(10,10) -> B(i)=matrix(10,10) input = vector of matrices, i = sample size output = vector of matrices Say I would like to guess an matrix operation transforming matrix into another matrix ie f(A(i,j))=2*A(i,j)*b Matlab do...

How can I sort a 2-D array in MATLAB with respect to 2nd row?

I have array say "a" a = 1 4 5 6 7 2 if i use function b=sort(a) gives ans b = 1 4 2 6 7 5 but i want ans like b = 5 1 4 2 6 7 mean 2nd row should be sorted but elements of ist row should remain unchanged and should be correspondent to row 2nd. ...

How can I create a collage in MATLAB?

I want to write a program that can create random collages from a given folder of pictures. To begin, I want to create a simple collage from three images. Something like this: I have almost no code right now clc; clear all; close all; a = imread('a.png'); b = imread('b.png'); c = imread('c.png'); % create a new image of size X x Y ...

Recognizing edges based on points and normals

Hi guys, I have a bit of a problem categorizing points based on relative normals. What I would like to do is use the information I got below to fit a simplified polygon to the points, with a bias towards 90 degree angles to an extent. I have the rough (although not very accurate) normal lines for each point, but I'm not sure how to sepa...

how to implement the idea of mvc design in matlab gui's

hi guys, please am a student working on a project to develop a visualization tool to analyse data using an mvc design in matlab. but the problem im having is that im new to programming and matlab is the first real programing im doing. ive pretty much done the codes but i fear they are no way in an mvc design pattern so i need to change t...

How to un-rectify an image in matlab?

Hi, I have rectified a pair of images (applying a rotation matrix (R) to them and then projecting it to the camera image plane), done with Fusiello method/code: (http://profs.sci.univr.it/~fusiello/demo/rect/) How can I un-rectify the image? Meaning inverse the rotation and re-project it. It would be useful, because the rectified image...

How can I extract peak values from auto-correlated data in MATLAB?

I have information (20,000 frames of data) about an audio track that I have auto-correlated using: [r,lags] = xcorr(XX,XX,'biased'); And it looks like this: Which hopefully is so far so good. Ideally I would like to be able to take the frame number that corresponds to the highest part of the second peak. I've read around and tried ...

Socket operation errors with MATLAB and the Parallel Computing Toolbox

We're using the MATLAB Parallel Computing Toolbox for one of our projects and we intermittently get the following error: The client lost connection to lab 2. This might be due to network problems, or the pmode parallel job might have errored. This is causing: java.io.IOException: An operation on a socket could not be performed because t...

Please help me to test my hypothesis with the neighbor elements in the matrix.

Hey guys, I could not figure out the last part of my research so if anyone could help me I would be really appreciated for the help.. :) Say that my original matrix is, X = 0 0 0 0 0 0 0 12 9 0 0 4 9 15 0 0 11 19 0 0 0 2 4 8 0 0 ...

2x2 QPSK for ZeroForcing

Heia... I'm trying to write the code QPSK with zeroforcing when N=2 and i got one error which i dont know how to fix it. plz help me. thanks alot here is the code: Modulation = 'QPSK' Decode_Method = 'ZeroForcing' switch Modulation case {'QPSK'} Symbols = [ 1+j 1-j -1+j -1-j ]'; end Symbols = Symbols.'; nSymbols = length...

ANNs in Matlab and FANN

How can I get a neural net file from Matlab into a FANN .net file ...

Apply function to all rows in matlab

I have a function, ranker, that takes a vector and assigns numerical ranks to it in ascending order. For example, ranker([5 1 3 600]) = [3 1 2 4] or ranker([42 300 42 42 1 42] = [3.5 6 3.5 3.5 1 3.5] . I am using a matrix, variable_data and I want to apply the ranker function to each row for all rows in variable data. This is my curren...

Compute set union of a cell array in Matlab

I have a cell array where each element consists of a vector of ids. I like to compute the union of all elements in the cell array. This is my current solution, but I feel it can be vectorized or have a more elegant solution: union_ids = union(encounter_ids{1},encounter_ids{2}); for i=3:1:numel(encounter_ids); union_ids = union(unio...

Matlab: correlation number

I have a 2 vectors of numbers of either 1 or -1. What are the standard tools on Matlab that would help me calculate a correlation number between the two vectors? Thanks in advance! ...

Creating a fade-in/fade-out function in MATLAB?

Hello, I am looking to create a function that could create a fade-in/fade-out function on a .wav file over a period of five seconds. I found this code on the MATLAB forums but it seems the implementation was slightly wrong, although the right idea is there. It was for .WAV files of 300ms with a 10ms fade-in/out: tenmssamples = length(...

Least squares fit routine for timescaling in Matlab

Dear all, I would like to know if there is a least squares routine in Matlab to scale a template signal to a measured signal in time. Let's say my template is a signal of approx. 1 second, but the corresponding part in the measurement is 1.2 seconds. Now I want to scale my template to be 1.2 seconds long as well. Of course it is possibl...