Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
min and end indexing syntax

Subject: min and end indexing syntax

From: Bruno Luong

Date: 7 Apr, 2011 14:07:21

Message: 1 of 9

Can someone please explain the error I get in the last statement, which seems to me as a simple contraction of the statements #2 and 3.

>> A=ones(2)

A =

     1 1
     1 1

>> B=A(min(1:3,end),min(1:4,end))

B =

     1 1 1 1
     1 1 1 1
     1 1 1 1

>> C=min(B)

C =

     1 1 1 1

>> min(A(min(1:3,end),min(1:4,end))) % min(B) in one statement
??? Error using ==> min
Not enough input arguments.
 
% Bruno

Subject: min and end indexing syntax

From: Matt J

Date: 7 Apr, 2011 14:21:21

Message: 2 of 9


I don't know, but whatever it is, it's occuring with the outer min, and is specific to min and not other functions, e.g.,


>> max( A( min(1:3,end) , min(1:4,end) ) )

ans =

     1 1 1 1


>> all( A( min(1:3,end) , min(1:4,end) ) )

ans =

     1 1 1 1

>> std( A( min(1:3,end) , min(1:4,end) ) )

ans =

     0 0 0 0

Subject: min and end indexing syntax

From: Florin Neacsu

Date: 7 Apr, 2011 16:10:23

Message: 3 of 9

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <inkgeo$9me$1@fred.mathworks.com>...
> Can someone please explain the error I get in the last statement, which seems to me as a simple contraction of the statements #2 and 3.
>
> >> A=ones(2)
>
> A =
>
> 1 1
> 1 1
>
> >> B=A(min(1:3,end),min(1:4,end))
>
> B =
>
> 1 1 1 1
> 1 1 1 1
> 1 1 1 1
>
> >> C=min(B)
>
> C =
>
> 1 1 1 1
>
> >> min(A(min(1:3,end),min(1:4,end))) % min(B) in one statement
> ??? Error using ==> min
> Not enough input arguments.
>
> % Bruno


Hi,

I am using matlab 7.5.0(R2007b) on XP and a linux box and I cannot reproduce this error.

>> A=ones(2)

A =

     1 1
     1 1

>> min(A(min(1:3,end),min(1:4,end)))

ans =

     1 1 1 1

>> A=[1,2;3,4]

A =

     1 2
     3 4

>> min(A(min(1:3,end),min(1:4,end)))

ans =

     1 2 2 2

Regards,
Florin

Subject: min and end indexing syntax

From: Bruno Luong

Date: 7 Apr, 2011 17:16:04

Message: 4 of 9

"Florin Neacsu" <fneacsu2@gmail.com> wrote in message
> Hi,
>
> I am using matlab 7.5.0(R2007b) on XP and a linux box and I cannot reproduce this error.
>

Hi Florin,

Correct, the code works fine on 2007b.

The bug occurs with 2010B Vista 64.

Bruno

Subject: min and end indexing syntax

From: Bruno Luong

Date: 9 Apr, 2011 08:15:14

Message: 5 of 9

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message
> The bug occurs with 2010B Vista 64.

2011A as well. :-(

Bruno

Subject: min and end indexing syntax

From: Matt J

Date: 9 Apr, 2011 12:24:04

Message: 6 of 9

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <inp4ii$80f$1@fred.mathworks.com>...
> "Bruno Luong" <b.luong@fogale.findmycountry> wrote in message
> > The bug occurs with 2010B Vista 64.
>
> 2011A as well. :-(
============

Oh well... Report it!

In the meantime, here's a workaround:

>> minwrap(A(min(1:3,end),min(1:4,end)))

ans =

     1 1 1 1

function varargout=minwrap(varargin)
%Wrapper for min, to avoid bug

 [varargout{1:nargout}]=min(varargin{:});

end

Subject: min and end indexing syntax

From: Matt J

Date: 9 Apr, 2011 12:41:02

Message: 7 of 9

"Matt J" wrote in message <inpj54$dsh$1@fred.mathworks.com>...
> "Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <inp4ii$80f$1@fred.mathworks.com>...
================

The plot thickens! I tried the modified workaround below, i.e. to define my own MIN which calls the builtin min. See if you can make sense of the following output:

>> min(A(min(1:3,end),min(1:4,end)));
 
NO INPUT ARGS PASSED!!!!
 
 
NO INPUT ARGS PASSED!!!!


function [varargout]=min(varargin)
 

if isempty(varargin)
  disp ' '
  disp 'NO INPUT ARGS PASSED!!!!'
  disp ' '
 
  varargout={1};
  
else
    
  [varargout{1:nargout}]=builtin('min',varargin{:});
  
end

Subject: min and end indexing syntax

From: Matt J

Date: 9 Apr, 2011 17:33:04

Message: 8 of 9

"Matt J" wrote in message <inkh90$q4p$1@fred.mathworks.com>...
>
> I don't know, but whatever it is, it's occuring with the outer min, and is specific to min and not other functions, e.g.,
>
>
> >> max( A( min(1:3,end) , min(1:4,end) ) )
>
> ans =
>
> 1 1 1 1
================================



I was wrong!! Check this out

>> max(A(max(1:2,end),max(1:2,end)))
??? Error using ==> max
Not enough input arguments.

Subject: min and end indexing syntax

From: Dan Golding

Date: 26 Feb, 2014 13:12:07

Message: 9 of 9

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <inkgeo$9me$1@fred.mathworks.com>...
> Can someone please explain the error I get in the last statement, which seems to me as a simple contraction of the statements #2 and 3.
>
> >> A=ones(2)
>
> A =
>
> 1 1
> 1 1
>
> >> B=A(min(1:3,end),min(1:4,end))
>
> B =
>
> 1 1 1 1
> 1 1 1 1
> 1 1 1 1
>
> >> C=min(B)
>
> C =
>
> 1 1 1 1
>
> >> min(A(min(1:3,end),min(1:4,end))) % min(B) in one statement
> ??? Error using ==> min
> Not enough input arguments.
>
> % Bruno

Was this ever resolved? I am facing a similar issue (only I don't have the out min). What's weird is that if I break the code and run my next line by copying into the command line it runs perfectly. However if I try run the next line through the debugger I get the error.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us