matlab

matlab 2009 creating symbol

how can i create symbolic variables in matlab 2009? because it doesn't work for "sym" o "syms" command. ...

Matlab loops for a function

Hi, I am trying to make a loop to redo a Matlab function 1000 times. Here's the program d = unifrnd (0,10,[10,1]); c = d.^(-2); a = round(unifrnd(0,1,[1,10]); e = a*c btotal = e+1 SIR = 1/btotal What I want is to iterate this function 1000 times, each time the value of SIR will vary due to the random number generated. For every iterat...

Quadtree Decomposition - MATLAB

How can I use the qtdecomp(Image,threshold) function in MATLAB to find a quadtree decomposition of an RGB image? I tried this: Ig = rgb2gray(I); % I is the rgb image S = qtdecomp(I,.27); but I get this error: ??? Error using ==> qtdecomp>ParseInputs A must be two-dimensional Error in ==> qtdecomp at 88 [A, func, params, min...

how to assign random energy E to every node and compare two nodes for maximum energy and also find distance between them?

As helped by gnovice I got following code, but now I want to assign energy (randomly) to every nodes using E=floor(rand(1)*10) and also want to compare for maximum energy and what is distance between them? N=input('no. of nodes : '); %# Number of nodes coords = num2cell(rand(N,2)) %# Cell array of random x and y coordin...

How can I display an error message in MATLAB?

I was doing a model for a slider-crank mechanism and I wanted to display an error for when the crank's length exceeds that of the slider arm. With the crank's length as r2 and the slider's as r3, my code went like this: if r3=<r2 error('The crank's length cannot exceed that of the slider') end I get the error: ??? error('The ...

How do I write an image to a file in MATLAB

I am particularly stuck in this case I = imread('liftingbody.png'); S = qtdecomp(I,.27); blocks = repmat(uint8(0),size(S)); for dim = [512 256 128 64 32 16 8 4 2 1]; numblocks = length(find(S==dim)); if (numblocks > 0) values = repmat(uint8(1),[dim dim numblocks]); values(2:dim,2:dim,:) = 0; blocks = qtsetblk(blo...

Importing text files with comments in MATLAB

Is there any character or character combination that MATLAB interprets as comments, when importing data from text files? Being that when it detects it at the beginning of a line, will know all the line is to ignore? I have a set of points in a file that look like this: And as you can see he doesn't seem to understand them very well. Is...

Generalized Gaussian Noise generator in matlab

I need to create Generalized Gaussian Noise generator in Matlab. GGN is a random signal v of following distribution: v ~ GN(mi, alfa, beta) : p(v; mi, alfa, beta) = (beta/(2*alfa*gamma(1/beta))) * exp(-(abs(v - mi)/alfa).^beta ) Where p is the probablility counted for value v. Note, that gamma is built in Matlab function that comp...

MATLAB - usage of knnclassify

When doing: load training.mat training = G load testing.mat test = G and then: >> knnclassify(test.Inp, training.Inp, training.Ltr) ??? Error using ==> knnclassify at 91 The length of GROUP must equal the number of rows in TRAINING. Since: >> size(training.Inp) ans = 40 40 2016 And: >> length(trainin...

How do I assign an empty matrix to elements of a cell array in MATLAB?

I want to manipulate a cell array and make certain indices of the cell array contain the empty matrix []. I can't seem to figure out how to do this: >> yy=num2cell(1:10) yy = [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] >> yy{1:2:end}=[] ??? The right hand side of this assignment has too few values to satisf...

MATLAB: displaying markup (HTML or other format)

I'd like to display a table from a script in MATLAB. I can easily generate the <td> and other HTML elements, but as far as I know, I can only write them to a file. Is there a way to display HTML (or some other markup) from MATLAB? Or am I stuck writing to a file and opening a browser? ...

How can I generate the following matrix in MATLAB?

I want to generate a matrix that is "stairsteppy" from a vector. Example input vector: [8 12 17] Example output matrix: [1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0] [0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1] Is there an easier (or built-in) way to do this than the following?: function M = stairstep(v) M = zeros(...

Curves in matlab

Just wanted to know if matlab had a function to plot curves instead of lines. Thank you in advance. ...

How do I make an "empty" anonymous function in MATLAB?

I use anonymous functions for diagnostic printing when debugging in MATLAB. E.g., debug_disp = @(str) disp(str); debug_disp('Something is up.') ... debug_disp = @(str) disp([]); % diagnostics are now hidden Using disp([]) as a "gobble" seems a bit dirty to me; is there a better option? The obvious (?) method doesn't work: debug_disp ...

How do I write a text file in the same format that it is read in MATLAB?

I have asked a related question in the past and I know how to read the file thanks to the help of the experts here. Now I have a new problem. I first read the data from the file like so: fid = fopen('D:\file.txt', 'rt'); a = textscan(fid, '%s %f %f %f %f %f %f', ... 'Delimiter',',', 'CollectOutput',1, 'HeaderLines',1); fclo...

Automatic selection of control points in Matlab

Hello, Is there a way to select the control points automatically in Matlab instead of manually selecting them by cpselect? Thank you very much. ...

A Simple Wrapper for F# to do matrix operations

Hi there! This is a relatively long post. F# has a matrix and vector type(in PowerPack not in the Core) now. This is great! Even Python's numerical computing ability is from the third part. But the functions provided there is limited to the matrix and vector arithmetic, so to do inversion, decompositions etc. we still need to use anot...

Turn off excel merge cell warning from matlab

I'm trying to merge cells in excel from Matlab and I keep getting a merge cell warning "It will only keep the..." and the person has to press ok to accept. How can I turn this off? ...

safe, fast CFLAGS for mex functions in matlab

I am converting a number of low-level operations from native matlab code into C/mex code, with great speedups. (These low-level operations can be done vectorized in .m code, but I think I get memory hits b/c of large data. whatever.) I have noticed that compiling the mex code with different CFLAGS can cause mild improvements. For exampl...

how to find remaining nodes in following code which are not participating in making edges with each other?

if you run following code with nodes N=10, you will get randomly picked few nodes with probability say P= .25 and marked as red nodes, then in, for loop every red colored node checking distance with remaining blue colored nodes.if distance is less than or equal to R say R =.2, Then it will plot edge between that red colored node and blue...