matlab

How can I reproduce this cuboid plot in MATLAB?

I dumped some frames of a video and would like to generate a cuboid out of them, like in the following sample image: I was wondering if there exists a MATLAB function to do such a plot? ...

MATLAB: Using interpolation to replace missing values (NaN)

Hello, I have cell array each containing a sequence of values as a row vector. The sequences contain some missing values represented by NaN. I would like to replace all NaNs using some sort of interpolation method, how can I can do this in MATLAB? I am also open to other suggestions on how to deal with these missing values. Consider t...

Receive UDP data from multiple sources in Matlab

I need to set up a UDP reader in Matlab that receives data from a number of sources. I typically use this for a single data source: [packet,~,~,senderaddress]=fread(s,s.BytesAvailable) The problems are that I want to avoid waiting for the timeout, I don't have terminated data arriving, and packets are of unknown sizes. Has anyone el...

Speed Comparison and suggestion for wise case in Matlab

Case 1: I have a nested for loop to run large realizations and save variables generated through that loop in .mat files, which I can later use in another program. Case 2: I can make the function of the above mentioned loop and call it directly in the other program where I want to use the variables generated by the above loop. The only...

Draw line between two subplots

I have two two-by-n arrays, representing 2d-points. These two arrays are plotted in the same figure, but in two different subplots. For every point in one of the arrays, there is a corresponding point i the other array. I want to show this correspondance by drawing a line from one of the subplots to the other subplot. The solutions i h...

When is it appropriate to use a cell array vs. a struct in Matlab?

If I want to store some strings or matrices of different sizes in a single variable, I can think of two options: I could make a struct array and have one of the fields hold the data, structArray(structIndex).structField or I could use a cell array, cellArray{cellIndex} but is there a general rule-of-thumb of when to use which data ...

Converting images in MATLAB

How to convert YUY2 images to RGB images in MATLAB? ...

Database Toolbox (sql-matlab) randomly returning different values for only windows 7 computer

Hey, So I am trying to use the database toolbox in matlab to query a database at my research lab, and on one specific computer, the results it returns from the same query changes each time you run the SAME query command. connPV = database('dbname','username','password'); Images = fetch(handles.connPV,['SELECT i.id, i.image_type_id, i...

How to declare a variable name consisting of other varables (MATLAB)?

I have a Variable that needs to be dependent on another variable inside a loop: for n=1:100 newfilename="NEW_FILE_1.txt" end where the "1" needs to be what ever n is: So 1 for the first loop and 2 for the second loop and so on and so forth. How do you set up declaring "newfilename" to have the variable "n" variable inside its name?...

String output in MATLAB

clc clear all ii=1; S =cell(size(30,1)); % cell size. for ii=1:1:3 rand_id= rand(1,1) *3; % Randomly generte a number between 1 to 3. if (rand_id<1) rand_id=1; % 0 is ommitted. else rand_id=floor(rand_id); end % rand_id will be used to open a previously saved file randomly. if (rand_id==1) f_...

Help understanding a definitive integral

I am trying to translate a function in a book into code, using MATLAB and C#. I am first trying to get the function to work properly in MATLAB. Here are the instructions: The variables are: xt and m can be ignored. zMax = Maximum Sensor Range (100) zkt = Sensor Measurement (49) zkt* = What sensor measurement should have been (50) ...

how can i view the last rows of a matrix using matlab

how can i view the last 10 rows of a matrix note that the matrix size is changing : rows= 50, 100 150...) ...

Clustering text in MATLAB

I want to do hierarchical agglomerative clustering on texts in MATLAB. Say, I have four sentences, I have a pen. I have a paper. I have a pencil. I have a cat. I want to cluster the above four sentences to see which are more similar. I know Statistic toolbox has command like pdist to measure pair-wise distances, linkage to calculat...

How to implement this function in MATLAB?

I am using a book with a function I would like to use. However I don't think I am getting the correct values from my function. Here is the instruction from the book: Here is the function as I have created it in MATLAB: function [ shortProbability ] = pShort( zkt, zktStar, short) if zkt > zktStar shortProbability = 0; else n...

Inserting rows into matrix matlab

I have a ~ 100000/2 matrix. I'd like to go down the columns, average each vertically adjacent value, and insert that value in between the two values. For example... 1 2 3 4 4 6 7 8 would become 1 2 2 3 3 4 3.5 5 4 6 5.5 7 7 8 I'm not sure if there is a terse way to do this in matlab. I took a look at http://www.mathwo...

Avoiding memory reallocation in Matlab

I am converting an implementation of an image segmentation method from C++ to Matlab. It is an iterative method that that make calls to two functions: em() and mpm(). Those two functions uses two reasonably big auxiliary matrices, so to avoid reallocating memory at every call in my C++ implementation, I have prealocated the memory for t...

Griddata with 'cubic' Interpolation Method Returns NaN

I found that if I use griddata Method with Cubic Interpolation method, for certain values of x, y, it will return NaN. One post says that this is because the x and y data are very near to convex hull. Any idea how to fix this? Edit: Note that I can't make sure that my inputs are monotonously increasing ( thus, gridfit doesn't work). T...

matlab stateflow vs. Rhapsody

In Rhapsody - after creating a class, one can create many similar objects (instances) of that class. In matlab's stateflow tool - one can create a state which is, as far as I know, an object. Is there a possibility to use a state in matlab's stateflow tool as a class and create one or more objects of it? ...

Function to ask a MATLAB program to wait for an event before continuing execution

I want to use two MATLAB sessions on the same machine to run two different programs. My problem is that at some stage, the first program must use some results of the second program. So, is there a function that may apply to the first program to expect a step up the appearance of a result. ...

Draw Matlab graphs with frame, ticks, on top of graph lines

Consider something like figure plot(sin(0:0.01:pi)) axis tight set(gca,'box','on','ticklength',[0.02 0.05]) then export the graph to PDF or whatever. The lines of the graph are on top of the tick labels and the axes. (Furthermore, the lines of the axes don't meet correctly, but that's another story.) Is there a way (that can be auto...