matlab

read angles in radian and convert them in degrees/minutes/seconds

n=0; disp('This program performs an angle conversion'); disp('input data set to a straight line. Enter the name'); disp('of the file containing the input Lambda in radian: '); filename = input(' ','s'); [fid,msg] = fopen(filename,'rt'); if fid < 0 disp(msg); else A=textscan(fid, '%g',1); while ~feof(fid) Lambda = A...

Matlab - applying low-pass filter to a vector?

If I have a simple low-pass filter, e.g. filt = fir1(20, 0.2); and a matrix with a list of numbers (a signal), e.g. [0.1, -0.2, 0.3, -0.4] etc, how do I actually apply the filter I've created to this signal? Seems like a simple question but I've been stuck for hours. Do I need to manually calculate it from the filter coefficients? ...

Gaussian smoothing in MatLab

For an m x n array of elements with some noisy images, I want to perform Gaussian smoothing. How do you do that in MatLab? I've read the math involves smoothing everything with a kernel at a certain scale but have no idea how to do this in MatLab. Im pretty new to this... ...

Gaussian filter in MATLAB

Does the 'gaussian' filter in MATLAB convolve the image with the Gaussian kernel? Also, how do you choose the parameters hsize (size of filter) and sigma? What do you base it on? ...

How to deal with name/value pairs of function arguments in MATLAB

I have a function that takes optional arguments as name/value pairs. function example(varargin) % Lots of set up stuff vargs = varargin; nargs = length(vargs); names = vargs(1:2:nargs); values = vargs(2:2:nargs); validnames = {'foo', 'bar', 'baz'}; for name = names validatestring(name{:}, validnames); end % Do something ... foo...

Error " Index exceeds Matrix dimensions"

Hi experts, I am trying to read an excel 2003 file which consist of 62 columns and 2000 rows and then draw 2d dendrogram from 2000 pattern of 2 categories of a data as my plot in matlab. When i run the script, it gives me the above error. I don't know why. Anybody has any idea why i have the above error? My data is here: http://rapidsha...

Using imtophat in Matlab

I'm trying to do top hat filtering in matlab. The imtophat function looks promising, but I have no idea how to use it. I dont have a lot of work with Matlab before. I am trying to look find basically small spots several pixels wide that are local max in my 2 dimensional array. ...

Deterministic Annealing Code

I would like to find an open source example of a code for deterministic annealing. It can be in almost any language: C, C++, MatLab/Octave, Fortran. I have already found a MatLab code for simulated annealing, so MatLab would be best. Here is a paper that describes the algorithm. Deterministic annealing is an optimization technique ...

Plotting in Matlab

How do you plot two figures at the same time in Matlab? Every time I use surf() it plots over the old one. Also, how do you save the images so you can export them to MS word or powerpoint or something? ...

Thresholding in Matlab

How do I threshold an image to find the local maxes in a robust way? I know I can just look at the data, visually guess at some appropriate h value, and do imextendedmax(I,h) where h is the threshold... but I'm looking for a more robust way to do it in Matlab. I'm pretty new to Matlab and coding so this is all foreign... Update No, I'd...

Analyzing data for noisy arrays

Using MATLAB I filtered a very noisy m x n array with a low-pass Gaussian filter, cleaned it up pretty well but still not well enough to analyze my data. What would the next step be? I'm thinking that signal enhancement, but am not sure how to go about this. Update Well, there are two different types of data sets actually; one is small...

Using MATLAB to find maxima for data with a lot of noise

I have noisy data set with three peaks in MATLAB and want to do some image processing on it. The peaks are about 5-9 pixels wide at the base, in a 50 x 50 array. How do I locate the peaks? MATLAB is very new to me. Here is what I have so far... For my original image, let's call it array, I tried J = fspecial('gaussian',[5 5], 1.5); C =...

Changing axes and color of plots in Matlab

How do you get rid of the axes and dotted line grids when you plot in Matlab? Also, how do I make subplots of subplots. Since that's probably not very clear, what I mean is the following... Let's say I have a 10x10x10 .mat file, so I open each of the 10 frames and plot what I have on each 10x10 frame. I generate 2 different plots for ea...

Extended maxima transform in Matlab

I use imtophat to apply a filter to an m x n array. I then find the local max using imextendedmax(). I get mostly 0's everywhere except for 1's in the general areas where I am expecting a local max. The weird thing is, though, that I don't get just one local max. Instead in these places I get MANY elements with 1's such as 00011100000 0...

Subplots of multidimensional arrays in Matlab

I have a 10x10x10 array, z. How do I plot everything in the SAME window so that I would have the 3 plots for z(:,:,1) and below it the three plots for z(:,:,2) etc.? This is what I have so far: for i = 1:10 z=z(:,:,i); figure(i) subplot(1,2,1) surf(z) %code, obtain new array called "new1"... subplot(1,2,2) surf(new1) %code,...

Converting from binary to original array values in Matlab

Given a 2D array that has been converted to binary, for some index values of the binary array how do you find the corresponding values in the original? Maybe something using ind2sub? ...

Converting from subarray coordinates to array coordinates

I know the center (x,y) coordinates of a subarray in terms of the subarray space and general array. For other parts of the subarray I also know the coordinates in the subarray space - but I want to find the coordinates in the general array? Is there an elegant way to do it in MATLAB? In principle I think you should still be able to find ...

Why is Matlab Stateflow 7.7 not throwing errors on undefined variables?

Previously in Matlab Stateflow 7.1 all variables and functions had to be included before they can be referred to in the state diagram or else it would throw an error when you tried to parse the diagram. But now in 7.7 it doesn't catch those kinds of errors. Its still compiling the diagram because it catches other syntactic errors. Am ...

How to convert a numeric variable to a string in MATLAB

A=rand(10) B=find(A>98) How do you have text saying "There were 2 elements found" where the 2 is general i.e. it isn't text, so that if I changed B=find(A>90) it would automatically no longer be 2. ...

Global image threshold in Matlab

When you use graythresh in Matlab it obtains a value that is a normalized between 0 to 1, so when you use a threshold for something else such as imextendedmax or im2bw how would you use graythresh? I guess you have to probably multiply it by something but what? ...