matlab

simple input/output question in MATLAB

Hi all, I've recently upgraded my Matlab from 6.5 to 7.7 and am also using the Image and Mapping toolboxes as well as a few others. What I'm currently trying to do is bring up-to-date a few of the M scripts in order for them to take a file in, keep it's projection and export the same image. I'm inheriting most of the code which I'm curr...

Removing zeros from a matrix - Not Sparse

I have a matrix x = [0 0 0 1 1 0 5 0 7 0] I need to remove all of the zeros such as x=[1 1 5 7] The matrices I am using are large (1x15000) I need to do this multiple times (5000+) Efficiency is key! ...

Matlab on cmd (winxp)

I've just started experimenting something with Matlab, and since I'm used to Vim's interface, I try to stay out of Matlab's editor as much as possible. What's troubling me is that every time I start a .m file, it brings up the interface. Is there a way to start test.m from a cmd line, and let it give output out on a cmd, as it would nor...

How to elegantly ignore some return values of a MATLAB function?

I was wondering if it was possible to get the nth return value from a function without having to create dummy variables for all n-1 return values before it. Let's say I have the following function in MATLAB: function [a,b,c,d] = func() a = 1; b = 2; c = 3; d = 4; Now suppose that I'm only interested in the third return value. This ca...

Matlab number to letter swapping

If I have a vector, for example: V = [ 1, 2, 3, 4 ]. Is there a way to change this to the letters [ a,b,c,d ]? ...

Matlab swapping

If I am given a string of letters abcd and I want to convert this to a vector V = [ 1,2,3,4], how can I do this? ...

How do I iterate through each element in an n-dimensional matrix in MATLAB?

I have a problem. I need to iterate through every element in an n-dimensional matrix in MATLAB. The problem is, I don't know how to do this for an arbitrary number of dimensions. I know I can say for i = 1:size(m,1) for j = 1:size(m,2) for k = 1:size(m,3) and so on, but is there a way to do it for an arbitrary number of di...

problem with MATLAB imread()

In my previous question I asked about Blind Deconvolution in Matlab. Now I have a new problem where I know how imread and imwrite works but I don't know where do the function call the image file from? in other words where do I store the image in order to call it using imread? ...

Matlab subclassing question

Question about subclassing in matlab, under the new class system. I've got class A with some protected properties: classdef Table < Base properties (SetAccess = protected, GetAccess = public) PropA = []; end %properties I'd like to make a subclass with some specialized features, and further restrict access to PropA. (i.e. make g...

Problem with Array type "DAMPAR" in MATLAB deconvolucy.m

Below is part of the code that i tried to edit from, MATLAB's deconvolucy. it appears to have problem with DAMPAR where the class type does not match. can anyone help or does anyone know a better way to call in an image that I (as in deconvolucy.m) would tolerate? [perhaps i should convert the image into array before use? how do i do ...

Project Euler problem 214, How can i make it more efficient?

I am becoming more and more addicted to the Project Euler problems. However since one week I am stuck with the #214. Here is a short version of the problem: PHI() is Euler's totient function, i.e. for any given integer n, PHI(n)=numbers of k<=n for which gcd(k,n)=1. We can iterate PHI() to create a chain. For example starting from 18: ...

Problems with displaying edited pictures in a GUI created in Matlab...

I have an assignment to create a GUI using the matlab built-in gui guide and am having a problem with displaying an edited picture. I need to have buttons that edit the picture (eg. remove red, blue, green components and rotate) and display that edited picture. I am using the imshow() to display the edited picture but it displays in a ...

Editing checkboxes in a Matlab GUI

Using the GUI guide editor in Matlab 2008b, I have run into a problem with check boxes. I have looked at numerous online tutorials and such but haven't found a solution. My problem is that I have a button that resets everything in the GUI (editing a picture). However, there are checkboxes in my GUI and I can't figure out how to desele...

Matlab / Java API callback

I'm designing an API (in Java) and expect to have users accessing the API from Matlab. The problem is that I want the API to provide a piece of functionality like: javaApi.waitUntilPredicateIsTrue(Predicate<JavaObj> test); My API (in the background) gets hold of instances of Java Obj (via some mechanism, e.g. polling). I want this API...

Appending a vector to an empty matlab matrix

I've got matlab code inserting n-dimensional points (n >1) into a matrix (myPointMatrix) and am having thoughts about how to insert the first point. Right now the program checks the size of myPointMatrix before inserting a point. If it is 1x1 myPointMatrix is set equal to the current point. Otherwise the current point is appended. This...

Showing results in MATLAB GUI

I'm using MATLAB GUIDE to create a simple GUI. I'd like to know which uicontrol I should use to show some results: editable text or static text. In addition, I don't want the new results to replace the old ones. ...

how to sketch a polygon in a matrix or binary image in order to use image processing functions?

I'm developing a matlab program in which I uses polygons(concave or convex). I need to use image processing functions like imdilate or imerode and etc on the polygons. To this end, I should convert my polygons to image. I wonder whether there is a way to sketch a polygon directly in a binary matrix (1's for foreground and 0's for backgro...

MATLAB GUI using GUIDE: List Box problem

I'm creating a MATLAB GUI that contains two uicontrol objects: a pushbutton and a listbox. I use the pushbutton to add file names to the listbox. When I run the GUI from the m-file it works fine. The problem occurs only when I run the .fig file itself. Here is the callback code and the error: function add_file_Callback(hObject, eventdat...

OCR: Convert edge into a vector path

Hello, I'm trying to build a simple OCR program as a project for an image processing class. So far I've been able to "read" an image containing just ones and zeros I differentiate between ones and zeros by first identifying edge contours, then counting the number of contours per character, such that 1=one contour, 0=two contours. ...

Compact MATLAB matrix indexing notation

I've got an n-by-k sized matrix, containing k numbers per row. I want to use these k numbers as indexes into a k-dimensional matrix. Is there any compact way of doing so in MATLAB or must I use a for loop? This is what I want to do (in MATLAB pseudo code), but in a more MATLAB-ish way: for row=1:1:n finalTable(row) = kDimensionalMa...