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.
> 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:
"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:
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.
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.