Search Comments and Ratings

go

Comments and Ratings

   
Date File Comment by Comment Rating
23 Nov 2009 Unique Rows for cell arrays Find the unique rows of a cell array containing columns with strings or scalars. Author: Jim Fig, Matt

This is much faster, and has no requirement as to types or ordering:

ii = 1;
while ii<size(A,1)
    tf = true(size(A,1),1);
    for jj = ii:size(A,1)
        if isequal(A(ii,:),A(jj,:)) && ii~=jj
            tf(jj) = 0;
        end
    end
    A = A(tf,:);
    ii = ii + 1;
end

For example, try it with:
A = {1,'red',magic(3);'blue',magic(4),'green';1,'red',magic(3)}

31 Oct 2009 COMBINATOR -combinations AND permutations Returns 1 of 4 different samplings on the set 1:N, taken K at a time. Author: Matt Fig Fig, Matt

Michele,
You didn't give very much information. If you put a number greater than 170 WHERE? And what other parameters? Why don't you just email me? I put my email in the help for that purpose. If you email me, show me EXACTLY what you did, don't be vague.

07 Sep 2009 35 Complete GUI Examples 35 working GUIs to read and learn. Author: Matt Fig Fig, Matt

Cyberfrog,
GUI_34 has a custom menubar. None of the GUIs in this collection are programmed with GUIDE. Please email me if you have more questions.

06 Sep 2009 35 Complete GUI Examples 35 working GUIs to read and learn. Author: Matt Fig Fig, Matt

Hello CyberFrog,
I am not sure what you mean by a "menu title" in GUI_25. There isn't supposed to be a menubar, if that is what you mean. I am using 2007b, and everything looks like it should here.

No *.fig file is generated because these are M-file GUIs. GUIDE works by generating two files, an M-File which has the code, and a figure file which has the graphics. These are simply two different ways of doing GUIs in MATLAB. I much prefer to write my GUIs without GUIDE for many reasons, only one of which is that I need to keep track of only one file!

This collection, as is stated in the description, is meant to help people write GUIs without using GUIDE.

04 Sep 2009 ATAN2_SAFE To perform the same function as Matlab built-in function atan2 but safely guarded against erroneous Author: Zhigang Xu Fig, Matt

Actually atan2 is fine. The source of the error in your example is this line:

[x2 y2 z2] = sph2cart(t2, p2, r2); % step 5b

The value of y2 should equal zero but there are round-off errors occurring. If you simply assign y2 = 0 after this line in your example, you will see that t1 is back at zero as expected. This has nothing to do with atan2.

04 Sep 2009 NUMUNIQUE Returns unique elements in an array and all the indices for the repetitious values. Author: Zhigang Xu Fig, Matt

Well done. About the only thing I would change would be to replace these lines:

n = 1:N;
d = diff([nan; x]);
d = d~=0;
n = n(d);

with

n = find(diff([nan; x]));

On my machines this can make a significant difference in speed. Other than that, great code!

20 Aug 2009 Newton Raphson method for transcendental equations This file computes roots of a given trancendental equation using the Newton-Raphson method. Author: Abhishek Basu Fig, Matt

Three comments.

1. I do not see where you mention that this file needs the symbolic toolbox to run. It does. I wouldn't have downloaded it if I had known that because I don't have the symbolic toolbox. You should update the description to reflect this requirement.

2. Rating your own files is not good behavior. Everyone expects that an author likes his own files or he wouldn't have submitted them. Please don't try to trick people into thinking your file is esteemed by the community. Let others rate your files, then your skills and file quality can grow, and people looking for a quality file won't be misled by false ratings.

3. A numerical alternative that works for Shahrir's problem is:
f = @(x) cosh(x).*cos(x) + 1;
rt = newtzero(f); % Found on the File Exchange.
x = -8:.1:8;
plot(x,f(x),'b',rt,f(rt),'*r')

19 Aug 2009 ColorWeight (double version) The color weight without weight. Author: PXlab Fig, Matt

us,

You're not use correct metric for this time frame evaluation. Pi==NaN with the reference parameter of half, in this case. So it is not of concern to you for this solution, and scientific resolution is fine.
Color is motion in detection of point reference metric!! This is the valid point you miss in your algorithm.

13 Aug 2009 35 Complete GUI Examples 35 working GUIs to read and learn. Author: Matt Fig Fig, Matt

Tanguy,
You are correct. I didn't mention resizable GUIs because I make all of my own GUIs non-resizable. Is there something you have in mind in particular? If so email me with your suggestion, and I may include it in the next update. Thanks.

09 Aug 2009 ds group contribution Author: naser rezakhani Fig, Matt

A script. Not one single comment, let alone explanation.

09 Aug 2009 AutoWarnDlg Self-terminating modal warning dialog with flashing icon Author: Jan Simon Fig, Matt

Works well. One thing I would like to see added is an optional second output which stores whether the dialog terminated due to timeout or user acknowledgment. That way if this was called from a code which was running automatically, the user could be notified that a warning was thrown earlier. This could be useful for debugging.

01 Aug 2009 Fractions Toolbox create and manipulate fractions (K+N/D) using exact arithmetic Author: Ben Petschel Fig, Matt

Great work!

28 Jul 2009 35 Complete GUI Examples 35 working GUIs to read and learn. Author: Matt Fig Fig, Matt

Thanks someone,
BUG! I should be using listboxtop, not value. Thanks, I will update that too.
Also, the suggestions for added exercises are coming into my email. Keep them coming! Any other GUI suggestions are welcome, simple or complex.

28 Jul 2009 35 Complete GUI Examples 35 working GUIs to read and learn. Author: Matt Fig Fig, Matt

I like the contents.m idea, and I might as well since a typo has already been found.

In the pdf I refer to a comment in GUI_30. I should have put GUI_32. File will be updated.

13 Jul 2009 N_PERMUTE_K All possible permutations of the elements of set N, taken K at a time, with repetition. Author: Matt Fig Fig, Matt

Juliette,

You cannot index the output of npermutek(1:5,5) into an array (nuc) of length 4! The index exceeds dimensions because the output of the above call to NPERMUTEK will have many '5's in it. You will get the same error by doing this:

nuc = 'ABCD'
R = nuc(5) % or nuc(6) or nuc(7), etc. nuc only has 4 elements!

This is not an NPERMUTEK problem, it a user misunderstanding the output problem.

07 Jul 2009 reshape2cube Reshape a vector into a cubic array Author: david s Fig, Matt

I am with Darren. Maybe a generalization would be more useful:

A = 1:5^2;
reshape2pow(A,2)
A = 1:5^3;
reshape2pow(A,3)
A = 1:5^4;
reshape2pow(A,4)
....

29 Jun 2009 Longest Common Substring Gives the longest common substring between two stings. Author: David Cumin Fig, Matt

Something is still wrong.

[D,G,S] = LCS('fbce','abcde');S
S =
bce

29 Jun 2009 flattin/merging nested cells {{a}, b, {c,{d;e}}} --> {a,b,c,d,e} Author: Oleg Komarov Fig, Matt

If you are going to use the recursive engine, you need to change your description. The depth of nesting this function can handle will be limited by the default recursion limit.
 
For example:
C = {3 5}; for ii = 1:1000,C = {C};end

25 Jun 2009 flattin/merging nested cells {{a}, b, {c,{d;e}}} --> {a,b,c,d,e} Author: Oleg Komarov Fig, Matt

Bruno,
In all fairness to Oleg, your code does not solve the same problem. Try this:

N = 10; c = {};
for ii = 1:N
    if round(rand)
       c = {num2cell(1:ii) c};
    else
        c = {mat2cell(ones(ii),ii,ii),c};
    end
end

tic
M1 = flatcell(c);
toc

tic
M2 = fcellrecurse(c);
toc

isequal(M1,M2) % Not necessarily.

To Oleg: In actuality, what Bruno's code does seems to me more useful. What is the purpose for flattening EVERYTHING in the cell?

25 Jun 2009 kronecker Kronecker tensor product Author: Bruno Luong Fig, Matt

Fast, slick, well done.
Thanks for answering my question. I was waiting on that in order to give a rating, now I know it is my old (!, 2007b) version of MATLAB which is out of alignment.

24 Jun 2009 EXPAND Replicate and tile each element of an array. Author: Matt Fig Fig, Matt

Another reason I bypassed kron is illustrated here:

http://i217.photobucket.com/albums/cc229/spamanon/tester_output-2.png

Urs, I think you are correct about mentioning kron in the see also.

24 Jun 2009 kronecker Kronecker tensor product Author: Bruno Luong Fig, Matt

My only question is why the function errors out for non- 2D inputs? The stock MATLAB function does not error, and if I take the offending lines of code out of kronecker, the results match.

24 Jun 2009 kronecker Kronecker tensor product Author: Bruno Luong Fig, Matt

Mayowa,

Indeed that is faster for smaller A,B. However, for larger A and B, kronecker is several times faster.

24 Jun 2009 EXPAND Replicate and tile each element of an array. Author: Matt Fig Fig, Matt

Hello Jos,

There are a couple of reasons I bypassed kron. The main reason is that expand, even with error checking etc., is faster on my machine(s):

A = reshape(randperm(24),6,4);
SZ = [300,400];
tic
T = expand(A,SZ);
toc %Elapsed time is 0.043622 seconds.
tic
T2 = kron(A,ones(SZ));
toc %Elapsed time is 0.082535 seconds.

For
A = reshape(randperm(144),18,8);
SZ = [300,400];
expand is .25 vs. .78 seconds for kron. 2007b win xp.

expand also works for your second example.
Thanks.

19 Jun 2009 Pollock Paint like Jackson Pollock in Matlab Author: James Roberts Fig, Matt

Cool idea! Works well.

17 Jun 2009 subarray Extracts a subarray from an array. Useful for function outputs. Author: Peter Mao Fig, Matt

You could also do this:

a = foo(x,y,z);
a = a(2,9:end);

Then there is no temporary variable polluting your workspace.

02 Jun 2009 findsubmat Finds one matrix (a sub-matrix) within another. Author: Matt Fig Fig, Matt

Siyi, Your code, as written, will work when there is one submatrix within A. However, it will need to be modified for multiple submatrices. Even without the modification, it is slower to use the approach you suggest. In the following, I made a copy of findsubmat, took out all of the NaN checking and the transposing of A, and put your code in the proper place. Here are some results:

A = round(rand(2000)*1);
B = [1 2;4 5];
A(30:31,60:61) = B; % Only one submatrix.

tic
C = findsubmat(A,B); % Elapsed time is 0.055974 seconds.
toc

tic
C = findsubmat_2(A,B); % Elapsed time is 0.502954 seconds.
toc

Also, this is really the kind of exchange that better takes place through email. Mine is listed in the help for findsubmat.
Feel free to email me about this code.
Thanks.

28 May 2009 isodd: a pedestrian parity checker ISODD returns TRUE for integers of any numeric MATLAB class that are not evenly divisible by 2 Author: us Fig, Matt

Finally, a standard file which can be referenced for the perennial NG question! Well done. Thanks Urs.

19 May 2009 PARTITIONS Finds all partitions of a set, or only those partitions of a specified length. Includes a viewer. Author: Matt Fig Fig, Matt

An update has been submitted which allows user to enter the set to be partitioned. For example: partitions(['a','b','c'])

18 May 2009 Set partition List all partitions a set n elements Author: Bruno Luong Fig, Matt

Very nice: smartly coded, fast, well implemented.

07 May 2009 mfiles/matfiles/figfiles Contains three functions for displaying different files with links. Author: Matt Fig Fig, Matt

Wolfgang, I realized that after I posted the screenshot. I believe that file was my first experience with that author. Funny to see it now and everyone knows where it came from :-).

05 May 2009 findsubmat Finds one matrix (a sub-matrix) within another. Author: Matt Fig Fig, Matt

Good point us, I will submit an update.

04 May 2009 N_PERMUTE_K All possible permutations of the elements of set N, taken K at a time, with repetition. Author: Matt Fig Fig, Matt

nargin is a built-in Matlab function, as is numel. Take these questions to email please! My email address is in the file.

04 May 2009 N_PERMUTE_K All possible permutations of the elements of set N, taken K at a time, with repetition. Author: Matt Fig Fig, Matt

Hoda,

numel is a built-in Matlab function which returns the Number of ELements in the argument. If your version of Matlab is too old to have numel, you may have to write your own. For vector inputs to npermutek, you can also replace numel with length.

01 May 2009 How fast is your graphics card? Creates a challenging 3-d benchmark for graphics processing speed measurement. Author: Michael Kleder Fig, Matt

4.4 on my Dell XPS M1710, ver 2007a, Vista Home Premium, Invidia GeForce Go 7900 GS

27 Apr 2009 MATLAB Responds to Greeting MATLAB replies back when you type "hi" into the command window, with eleven possible responses. Author: Ahmad Fig, Matt

Looking at the code I have some suggestions.

Do you really need the vector M? (No)
Why not put all your responses into a 12x1 cell then index into the cell array instead of nesting so many if else statements? Or you could use a switchyard.
Why is your function named cold_chat but saved as hi?

03 Apr 2009 Conditional Nonparametric Kernel Density Condtional Kernel Density Estimate with normal kernel and LSCV bandwidth selection Author: Taesam Lee Fig, Matt

Please don't rate your own files.
Everyone assumes the author likes the file.

25 Mar 2009 Get the Slope and Intercept of drawn Lines You have to draw a line in a graph to obtain the slope of a curve or of its tangent. Author: Jean-Luc Dellis Fig, Matt

This really needs some improvement. Since there is no help of any value, I had to read a bit of the code to figure out what I was supposed to do.

>> plot(1:10)
>> getslopeintercept
??? Cell contents reference from a non-cell array object.
Error in ==> getslopeintercept at 21

Fix the code and have a look at the help for the Matlab function 'max' as an example of how to write the help for your function.

19 Mar 2009 FIND for n-D: Find indices and values of nonzero elements in n-D matrix FINDN is the FIND function for n-D matrix Author: H. Brian Hui Fig, Matt

This seems a little faster for large number of dimensions:

IDX = find(A);
L = size(A);
[x{1:length(L)}] = ind2sub(L,IDX);
sub = [x{:}];
if nargout==2
    v = A(IDX);
end

Something to consider.

19 Feb 2009 axescenter Puts axes in the center of a plot. Zooming, panning and some command line manipulations allowed. Author: Matt Fig Fig, Matt

Sergei noticed that if the parent of the current axes is not a figure, AXESCENTER will not position correctly. He had called AXESCENTER for an axes that was in a uipanel. An update is on the way.

13 Feb 2009 axescenter Puts axes in the center of a plot. Zooming, panning and some command line manipulations allowed. Author: Matt Fig Fig, Matt

I realized I should have a check that the input arg is a handle of the correct type. Update on the way.

10 Feb 2009 Quadratic Equation Calculator Quadratic Equation Calculator Author: Diego Orlando Barragan Guerrero Fig, Matt

I gave two stars because by running this program, the root is changed then not changed back. That is not a good way to make users of your code happy. When the user closes the GUI, you need to set colordef back to what it was prior to initialization. I will change my rating when this is fixed.

10 Feb 2009 Quadratic Equation Calculator Quadratic Equation Calculator Author: Diego Orlando Barragan Guerrero Fig, Matt

In the lines where you calculate the quadratic formula, you need a parenthesis around the 2*a, like this;
x1=(-b+sqrt(b^2-4*a*c))/(2*a)
x2=(-b-sqrt(b^2-4*a*c))/(2*a)
Otherwise your solutions are only valid for a = 1.

24 Dec 2008 Matfig2PGF Convert figures to PGF files that can be included in LaTeX documents. Author: Paul Wagenaars Fig, Matt

I like the name!

13 Nov 2008 Min Max Game A simple guessing game between the number 1 and 100. Author: Christine Fig, Matt

This is a script that issues a clear command - NOT A GOOD IDEA. Please only submit functions to the file exchange. There is no need for 3 separate files to make the game you want. Everything you are using the ask.m and check.m functions to do can be done in a simple while loop!

31 Oct 2008 whats Duplicates the output of Matlab function WHAT, with clickable links. Author: Matt Fig Fig, Matt

Hey Mike, my email address should be listed at the bottom of the help for all of my files on the FEX. Thanks.

 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com