matlab

Producing 2D array from a 1D array in MATLAB

Does anyone know if there is a way to produce a 2D array from a 1D array, where the rows in the 2D are generated by repeating the corresponding elements in the 1D array. I.e.: 1D array 2D array |1| |1 1 1 1 1| |2| |2 2 2 2 2| |3| -> |3 3 3 3 3| |4| |4 4 4 4 4| |5| |5 5 5 5 5| ...

matlab fxn: find contiguous regions and return bounds in struct array

Hi everyone, This is half a question and half a challenge to the matlab gurus out there: I'd like to have a function take in a logical array (false/true) and give the beginning and ending of all the contiguous regions containing trues, in a struct array. Something like this: b = getBounds([1 0 0 1 1 1 0 0 0 1 1 0 0]) should retu...

simulation of oqpsk

hi for the simulation of oqpsk i have written the below values = [0;1;0;0;1;0;1;0]; h = modem.oqpskmod; y = modulate(h, values); g = modem.oqpskdemod(h); z = logical(demodulate(g,y)); BER = sum(values(:)-z(:))/numel(values); my questions are as follows: 1) how can i verify that it does what i expect it to d...

matlab: manipulating two linked matrices

hi, I was wondering what best practices are for the following: i have two matrices, a1(500,40) and a2(1,500) and for a1, which is boolean, i want to separate out the arrays depending on the values in a particular column (ie. true or false), i would also need to separate the corresponding entry in a2. i can do this with a couple of loo...

What do end-of-line commas do in Matlab?

I swear I used to know, but this is hard to look up: what do the end-of-line commas do in Matlab? In the couple of small tests I've done, they don't seem to make the code behave any different. I'd like to know because they're all over in this code I didn't write (but have to maintain). Examples of what I mean: if nargin<1, % cod...

Matlab: convert function to simulink block

How do I convert from a function that I have written as an m-file into a block in Simulink model? I couldn't find anything on Google that tells me how to do that easily, so it would be much appreciated if any of the readers here can help point me in the right direction. ...

how to draw concentric circles in an image in MATLAB?

Here is my code.... I want to draw concentric circles in a fingerprint image.. please help clear all clc id=imread('C:\Documents and Settings\Administrator\Desktop\DB1\101_2.tif'); a=size(id); sd=a/2; s=3; circle([sd(1),sd(2)],3,1000,':'); circle([sd(1),sd(2)],6,1000,':'); circle([sd(1),sd(2)],9,1000,':'); circle([sd(1),sd(2)],12,1000...

SQL to extract matlab date from postgres db

I'd like to construct a query to "convert" a postgresql datetime to a matlab datenum. Experience with other DBs has shown me that converting the date on the DB side is much faster than doing it in matlab. Matlab stores dates as number of days (including fractions) since an arbitrary epoch of a gregorian, non-existent date of 00-00-0000...

what advantages MATLAB has over SCILAB and vice versa ?

hello i'm a computer systems engineering undergraduate student, i just want to know what advantages MATLAB has over SCILAB and vice versa other than that SCILAB is freeware. i mean from a computer engineer point of view. thanks ...

Setting the variables of Solve in MATLAB

In MATLAB, I have an equation a*x+b=0 for which I have a and b defined during execution. What is the best way I can solve the equation using what I've set for a and b. ...

Vectorizing for loops in Matlab

I'm not too sure if this is possible, but my understanding of Matlab could certainly be better. I have some code I wish to vectorize as it's causing quite a bottleneck in my program. It's part of an optimisation routine which has many possible configurations of Short Term Average (STA), Long Term Average (LTA) and Sensitivity (OnSense) ...

What's the correct syntax for applying a function to sub elements of a matrix without using a loop?

I have a defined a function (GetDepth) which does something fairly trivial, eg takes in a 2x4 matrix and outputs a 2x1 matrix. I then have an 2x4xn matrix I want to apply it to, and I'm expecting an 2x1xn matrix result. What is the correct syntax to apply my function to the matrix without resorting to using a loop? ed. As requested, h...

modem.oqpsk with half sine wave

hi i was using the following h = modem.oqpskmod; but it constructs it with default settings, i wanted to model zigbee one which is oqpsk with half sine waves... how could i do it? thanks a lot! ...

reading a text file to matlab with different formatting

Hi I have a text file, but unfortunately its been poorly formatted, however i want to read the content of the text file into a a matrix, but I dont know how to do that. the when try to use fscanf, textscan,textread and the rest it just copies everything into one cell, but i dont want it that way. this how the content looks like: so i wan...

Detecting center point of cross using Matlab

Hello, I have an image as shown above. Is it possible for me to detect the center point of the cross and output the result using Matlab? Thanks. ...

How do I label two vectors in Matlab?

I have a 2 column matrix(called M, which I visualize as two vectors using Matlab's plot command(plot(M)). I have two issues: I want to label the vectors themselves on the plot. I want to label each row of the matrix(i.e. each vector component) on the plot. How would I go about doing those things? ...

descontinuous initial data

I have a discontinuous function like f(x)=0.5(exp(-80x^2)+1) if -0.3<x<-0.1 and f(x)=0.5exp(-80x^2) otherwise, with the domain 0 ≤ x ≤ 1. How to define it as inline function in MatLab? ...

sorting colors in matlab

I have different RGB values in a 260000 * 3 dimension array. I wan to sort these colors in ascending or descending order (it does not matter which) so that similar colors are closer. What's the most efficient way to do this? ...

How do I detect if I'm running MATLAB or Octave?

I need to write code that should run equally well in Octave and on MATLAB. Problem is that it needs to do some GUI stuff, which MATLAB and Octave handle completely differently. Is there a way I can detect if I'm running MATLAB or Octave, in order to call the right function? ...

intersection of two line

how can one obtain coordinates of intersections of two line diagrams with given expression or equation? for example: L1= sin(2x) , L2= Ln(x); or anything else. ...