Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: Suggesting improvements to Matlab

Subject: Suggesting improvements to Matlab

From: Oliver Woodford

Date: 03 Aug, 2007 15:41:21

Message: 1 of 7

Hi all

I'm sure we all have improvements we'd like to make to
Matlab - my colleagues and I are forever discussing them. I,
for one, have no idea how to go about suggesting them to
MathWorks, but doubt they would be implemented if I did
anyway. Instead I thought I'd send them here for feedback
and to gauge support. Others might add their own suggestions
also. One of the MathWorks team might see them too.

Firstly it's important to note that improvements should not
break any old code - I don't believe these do, as long as
the code doesn't rely on any errors occurring (which may no
longer occur due to extended functionality).

Improvements to array operators (+, -, .*, ./):
Currently you can use these on two matrices of the same
size, or a matrix and a scalar.
I would like them to also be valid for a larger set of pairs
of matrices, which would include any pair of matrices A and
B where each dimension of A is either the same as the
respective dimension of the B, or 1.
This would allow you to combine (using the above operators)
A and B, where (for example):
size(A) = [1 3 4 1 1];
size(B) = [10 3 4 7 2];
Currently you would do:
B + repmat(A, [10 1 1 7 2]);
or use nested for loops.
The benefit of having this functionality built in is that
you don't need to waste time and memory replicating data (or
 doing for loops). It would be especially useful when B is
huge and A is small.

Improvement to print():
Currently print can send a figure to a printer or save it to
 a file. I would like it to also be able to save a figure as
a bitmap in a Matlab array. This would enable me to do some
post processing on the figure, without having to reload it
from disk (slow). It would also allow getframe() to use
print(), instead of doing its crazy screen grabbing trick
which causes the current figure to be brought into focus -
very irritating if you are trying to do something else.

Improvement to size():
Currently size only returns one or all dimensions. However,
I may want a subset of dimensions. It would be nice if size did:
function S = improved_size(A, d)
S = size(A);
if nargin > 1
   S = S(d);
end
return
This means I can write size(A, [1 2]) and get back the first
two dimensions only. Clearly I can use the above function
instead, but why isn't it built in to size()?

Edit the status bar (right of 'Start' button):
It would be great to be able to write to the status bar.
This would allow you to display info on the progress of a
function without needing a separate figure or waitbar.

Olly

Subject: Re: Suggesting improvements to Matlab

From: Peter Boettcher

Date: 03 Aug, 2007 15:50:49

Message: 2 of 7

"Oliver Woodford" <o.j.woodford.98@cantab.net> writes:

> Hi all
>
> I'm sure we all have improvements we'd like to make to
> Matlab - my colleagues and I are forever discussing them. I,
> for one, have no idea how to go about suggesting them to
> MathWorks, but doubt they would be implemented if I did
> anyway. Instead I thought I'd send them here for feedback
> and to gauge support. Others might add their own suggestions
> also. One of the MathWorks team might see them too.
>
> Firstly it's important to note that improvements should not
> break any old code - I don't believe these do, as long as
> the code doesn't rely on any errors occurring (which may no
> longer occur due to extended functionality).
>
> Improvements to array operators (+, -, .*, ./):
> Currently you can use these on two matrices of the same
> size, or a matrix and a scalar.
> I would like them to also be valid for a larger set of pairs
> of matrices, which would include any pair of matrices A and
> B where each dimension of A is either the same as the
> respective dimension of the B, or 1.
> This would allow you to combine (using the above operators)
> A and B, where (for example):
> size(A) = [1 3 4 1 1];
> size(B) = [10 3 4 7 2];
> Currently you would do:
> B + repmat(A, [10 1 1 7 2]);
> or use nested for loops.
> The benefit of having this functionality built in is that
> you don't need to waste time and memory replicating data (or
> doing for loops). It would be especially useful when B is
> huge and A is small.

The new function bsxfun in MATLAB 7.3 does this. For your example:

bsxfun(@plus, A, B)


-Peter

Subject: Re: Suggesting improvements to Matlab

From: Oliver Woodford

Date: 03 Aug, 2007 16:12:10

Message: 3 of 7

> The new function bsxfun in MATLAB 7.3 does this. For your
example:
>
> bsxfun(@plus, A, B)

Brilliant!

Subject: Re: Suggesting improvements to Matlab

From: us

Date: 03 Aug, 2007 16:40:11

Message: 4 of 7

Oliver Woodford:
<SNIP wants improvements that already exist...

> Edit the status bar (right of 'Start' button...

well, fortunately <yair altman> has already solved this
problem for you...

http://www.mathworks.com/matlabcentral/fileexchange/loadFile
.do?objectId=14773&objectType=file

us

Subject: Re: Suggesting improvements to Matlab

From: Steven Lord

Date: 03 Aug, 2007 17:00:56

Message: 5 of 7


"Oliver Woodford" <o.j.woodford.98@cantab.net> wrote in message
news:f8vib1$sb7$1@fred.mathworks.com...
> Hi all
>
> I'm sure we all have improvements we'd like to make to
> Matlab - my colleagues and I are forever discussing them. I,
> for one, have no idea how to go about suggesting them to
> MathWorks, but doubt they would be implemented if I did
> anyway. Instead I thought I'd send them here for feedback
> and to gauge support. Others might add their own suggestions
> also. One of the MathWorks team might see them too.

The best way to send them to us is to use the first link under "Product
Feedback" on the Contact Us page linked at the top of most of the pages on
The MathWorks website:

http://www.mathworks.com/company/aboutus/contact_us/

or, if you're in a country where we have a local office, you can contact
that office. They'll make sure to enter your suggestions into our
enhancement database. [Of course, you can both post them here and send them
to us via that form. You should mention that in your post if you do both
send and post.]

Sending your enhancement requests to your local office or to our
headquarters here in Natick lets us track how many users request each
feature more consistently than if we simply copy the request off the
newsgroup.

> Firstly it's important to note that improvements should not
> break any old code - I don't believe these do, as long as
> the code doesn't rely on any errors occurring (which may no
> longer occur due to extended functionality).
>
> Improvements to array operators (+, -, .*, ./):
> Currently you can use these on two matrices of the same
> size, or a matrix and a scalar.
> I would like them to also be valid for a larger set of pairs
> of matrices, which would include any pair of matrices A and
> B where each dimension of A is either the same as the
> respective dimension of the B, or 1.
> This would allow you to combine (using the above operators)
> A and B, where (for example):
> size(A) = [1 3 4 1 1];
> size(B) = [10 3 4 7 2];
> Currently you would do:
> B + repmat(A, [10 1 1 7 2]);
> or use nested for loops.
> The benefit of having this functionality built in is that
> you don't need to waste time and memory replicating data (or
> doing for loops). It would be especially useful when B is
> huge and A is small.

As Peter mentioned, this is possible with BSXFUN. If we made the existing
operators behave the same way as BSXFUN did, though, as you note it would be
a backwards incompatibility in that code that depended on (to use your
example) A+B throwing an error would change behavior.

We do have an entry in our enhancement database to consider a way to have
the functionality of BSXFUN in operator form.

> Improvement to print():
> Currently print can send a figure to a printer or save it to
> a file. I would like it to also be able to save a figure as
> a bitmap in a Matlab array. This would enable me to do some
> post processing on the figure, without having to reload it
> from disk (slow). It would also allow getframe() to use
> print(), instead of doing its crazy screen grabbing trick
> which causes the current figure to be brought into focus -
> very irritating if you are trying to do something else.

There's an entry for that in the enhancement database as well.

> Improvement to size():
> Currently size only returns one or all dimensions. However,
> I may want a subset of dimensions. It would be nice if size did:
> function S = improved_size(A, d)
> S = size(A);
> if nargin > 1
> S = S(d);
> end
> return
> This means I can write size(A, [1 2]) and get back the first
> two dimensions only. Clearly I can use the above function
> instead, but why isn't it built in to size()?

That's also in the enhancement database.

BTW, your function would need to be slightly tweaked:


function thesizes = mysize(A, dims)
% Get the sizes of A
n = size(A);
if nargin < 1
  thesizes = n;
  return
end
% Preallocate the vector/matrix output
thesizes = ones(size(dims));
% Mask for those elements of dims > ndims(A)
ldA = (n <= numel(thesizes));
% The engine
thesizes(ldA) = n(dims(ldA));


If you ask for the size of a matrix in a dimension greater than the number
of dimensions it has, you receive 1. For instance, size(ones(2, 3), 795)
returns 1.

> Edit the status bar (right of 'Start' button):
> It would be great to be able to write to the status bar.
> This would allow you to display info on the progress of a
> function without needing a separate figure or waitbar.

This, too, is in the enhancement database. Thanks for the good suggestions.

--
Steve Lord
slord@mathworks.com


Subject: Re: Suggesting improvements to Matlab

From: Oliver Woodford

Date: 03 Aug, 2007 17:24:56

Message: 6 of 7

Clearly I have underestimated MathWorks! Apologies and
thanks, Steve.

Subject: Re: Suggesting improvements to Matlab

From: Oliver Woodford

Date: 03 Aug, 2007 17:30:46

Message: 7 of 7

> well, fortunately <yair altman> has already solved this
> problem for you...
>
> http://www.mathworks.com/matlabcentral/fileexchange/loadFile
> .do?objectId=14773&objectType=file

Now that is handy. I looked on the exchange, though
admittedly not since April! Nice one, Yair, and thanks for
the tip, Us.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
reference us 03 Aug, 2007 12:41:07
improvement Oliver Woodford 03 Aug, 2007 11:45:21
rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
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 Disclaimer prior to use.
Related Topics