[DEPRECATED] What frustrates you about MATLAB?

Oliver Woodford on 16 Feb 2011
Latest activity Reply by DB on 13 Jun 2023

I love MATLAB. It is so quick and easy to write software to do what you want. It has excellent debugging and profiling tools. It is cross platform, making code easy to share (assuming the other people have forked out for the not-so-cheap license). It has interfaces to other software.
However, there are some things about it that irk me. I'd like to hear from other people what things annoy them about MATLAB.
---------------------------------
Because this thread has become so large it is slow to load and navigate. Please post new answers in the second thread.
---------------------------------
Rik
Rik on 10 Dec 2022
I was given to understand when the move feature was introduced that moving to a different thread would be possible in the future. I don't know the timeline for that feature or whether they're still working on it. It might come together with a different change I'm expecting to be done somewhere in the next 6 months.
Moving between threads will really help keeping threads like this clean, as I could move 110 answers to two different threads to get this one back to 50. It will take me an afternoon, but the end result would be navigateable threads.
DGM
DGM on 10 Dec 2022
Oh. I was afraid that's what happened.
:( seconded
Stephen23
Stephen23 on 10 Dec 2022
"Can't we just move new answers to the most-recent thread?"
That is what I just tried with the above comments, but it seems that moving only works within a thread :(
DGM
DGM on 10 Dec 2022
Can't we just move new answers to the most-recent thread? I'm reluctant to try it myself, since these extra-heavy pages almost never load correctly on my connection, and I've already had to deal with items which won't move or don't move completely after I touch them.
EDIT: I guess this "structs" thread is now in a pile of comments instead.
Rik
Rik on 10 Dec 2022
@Bruno Luong Unfortunately the only current way that is possible is by closing the thread, which has its own downsides. That is one of the reasons I have asked for a soft-lock option to be implemented.
I don't think reading the opening post is an unreasonable thing to expect, especially if you expect anyone to bother reading your comment.
Bruno Luong
Bruno Luong on 10 Dec 2022
"why did you ignore the comment at the top and post your answer in this thread?"
If you don't want people to post here then this thread should be locked. People just do search and they end up here, and no one bother to read the instruction before posting, they end up here alreadu frustrated (by MATLAB).
Rik
Rik on 10 Dec 2022
The 'problem' in this case is that x.a produces a comma separated list. It is equivalent to x(1).a,x(2).a,...,x(end).a. When you understand that, this behavior makes perfect sense.
And regarding jsondecode; the behavior is deterministic and documented. It depends on whether Matlab can tell the input structs would be the same. If they are, the result will be a struct array.
You can also follow it up with a function that converts a struct array to a cell array of structs if you prefer.
More importantly, why exactly is this being posted in this thread instead of the second thread? On mobile this page will not load properly anymore, and even on some computers it is getting harder. @Etienne Grossmann why did you ignore the comment at the top and post your answer in this thread?
Samuel Gray
Samuel Gray on 10 Dec 2022
I suppose this depends on what you mean by "frustration". I usually think of it as reward -effort. Now I can see where possibly someone might want to make an array of structures. A directory-search returns a structure, so if you were to dir of a tree, that would return an array of structures. That doesn't require any funky javish code. If you're going to down that rabbit-hole it's a matter of documentation as much as anything else, right? And I totally agree that when documentation is incomplete or just not there or obtuse, AND i REALLY NEED TO DO SOMETHING THAT RELIES HEAVILY ON THE DOCUMENTATION, that yes it can be frustrating. If I can't find an easier, better way to do it. I had a very bad experience with this using the Signal Communications toolbox to try to do tcp and udp data transfers in Win10. Turns out this is a long-standing problem. Because MS came out with an entirely new & different proprietary network stack which does not work with the Windows version of Matlab. It works fine with the Linux version. But the real solution is to just use the pcap stack. Or, you know, get a good book on winsock and have at it. The point is that you have to balance need and "available options" against difficulty, time and net frustration. It's not about getting X(:) done with toolset Y(:) it's about figuring out how to create and organize a custom toolset-documentation combination to solve an appropriate set of problems in an appropriate amount of time and effort. "Appropriate". Use it like play-dough. It's great. Solves every problem.
Walter Roberson
Walter Roberson on 10 Dec 2022
You could, of course, reduce it all to cells, like
x4 = {{3, 100}, {4, 200}};
whos x4
Name Size Bytes Class Attributes x4 1x2 656 cell
Besides the fact that this takes more memory than the struct array, you have the problem that you have to pass around a "key" everwhere in order to use this data. structs associated information with a name -- to use a field of a struct you do not need to know the relative position of the field within the struct, you only have to know the name of the field. Cell arrays on the other hand, you have to know which index is associated with each data item.
Walter Roberson
Walter Roberson on 10 Dec 2022
x1(1).a = 3; x1(1).b = 100;
x1(2).a = 4; x1(2).b = 200;
x2 = struct('a', {3, 4}, 'b', {100, 200});
x3 = {struct('a', 3, 'b', 100), struct('a', 4, 'b', 200)};
isequal(x1, x2)
ans = logical
1
whos x1 x2 x3
Name Size Bytes Class Attributes x1 1x2 576 struct x2 1x2 576 struct x3 1x2 912 cell
Notice that the cell version takes more memory. When you have a cell of scalar structs, then the name to offset information has to be repeated for each one of the entries, whereas for a struct array, the name to offset information is the same for each index.
Etienne Grossmann
Etienne Grossmann on 10 Dec 2022
Thanks Paul, that was instructive!
I still have doubts about the utility of struct arrays. I think they're at best redundant w/ structs and cells, and an extra complication to the language.
I'd rather not need a bachelor of science in Matlab in order to program in Matlab.
As a practical disadvantage, if I already have dozens of functions that work w/ cells of structs, and jsondecode() returns sometimes struct array, sometimes cell of structs, it means I can't use jsondecode(), and must use something else to load json files.
Paul
Paul on 10 Dec 2022
Create an example struct array
x1(1).a = 3; x1(1).b = 100;
x1(2).a = 4; x1(2).b = 200;
x1.a
ans = 3
ans = 4
How do I access the second element?
Like this, if I understand the question correctly
x1(2).a
ans = 4
Etienne Grossmann
Etienne Grossmann on 10 Dec 2022
struct arrays are pretty unusable. Example:
Only workaround I know of:
foo = {x1.a}; % Looks like a cell w/ one element, but it is not so
foo{2}
Worse, the function jsondecode() sometimes returns a cell of structs (good), sometimes a struct array.
yang
yang on 19 Oct 2022
I think the main problem I encountered was that I did not learn the basic content of this programming in the class first, but I directly got used to some difficult homework. As a result, I can only operate the software simply, but cannot use the software flexibly.
Rik
Rik on 22 Oct 2022
Why is this discussion happening in this thread? Even on a desktop this page is horrible to navigate. Chrome nearly crashed when I moved your answer to a comment.
Samuel Gray
Samuel Gray on 21 Oct 2022
Good project-management is based on the fundamental principle that given enough time, intellect, morals, ethics and effort, a good answer will come forward in a good timeframe and the problem will be resolved in a good way. There's no need to exend the question to the ridiculous, we don't need an Einstein or Plato here to resolve this question.
Matlhworks just can't waste time and resources answering every question or meeting every feature-request that users have. If they really need to know they will figure it out, if not they will work with what they already know.
Image Analyst
Image Analyst on 21 Oct 2022
@Samuel Gray I love steep learning curves. If you plot learning or knowledge gained vs. time, the steeper (more vertical) the better. I mean who woudn't want to learn a lot in a short time? A flat learning curve means little learned over a long time. Who would want that? So I think the learning curve is fortunately pretty steep for the basics but after that, it flattens out when/if you start to learn the fancier, more sophisticated features. I learned more in the first 3 months of programming in MATLAB than I've learned in the 16 years since then.
The expert quote I like best is from Nicholas Butler, president of Columbia University:
“An expert is one who knows more and more about less and less until he knows absolutely everything about nothing.”
@Walter Roberson and @Yair Altman are probably the two most expert about MATLAB, possibly even knowing more about it than the Mathworks staff, or even @Cleve Moler (Founder of MATLAB).
Walter Roberson
Walter Roberson on 21 Oct 2022
I am not convinced that anyone can master all of the commands and toolsets entirely.
Such a person would have to be able to (for example) design the mechanical (Simscape Mechanical) and electrical (Simscape Electrical) and fluid (transmission, gas) (Simscape Fluid) systems for a self-driving car with integrated sensors (Self Driving toolbox, Lidar Toolbox), and its data systems (Data Acquisition toolbox, CAN BUS blockset), build a 5G transmission protocol (5G toolbox, Communications System) including designing the antenna (Antenna Toolbox), and the car would have to be scanning the people it passed by cameras (Image Acquisition, Computer Vision, Vision HDL) and listen to them speak (Audio System) and run through prediction models (Deep Learning) to recognize whether they had any tumours or other illnesses, and if so then model the pathology (SimBiology), and use it to make predictions about which stocks to buy (Finance Toolbox)... and other things as well.
That is, in order to "master" all those toolboxes, you need to be fairly well acquainted with all of the areas of human and scientific knowledge covered by the toolboxes.
“It’s been said [Thomas] Jefferson was the last man to engage with success all the knowledge of his time,” as a statesman and student of letters, language, architecture, religion, philosophy, mathematics, astronomy, and natural sciences, Moses said. -- but the article also makes it clear that he "lacked the military and financial acumen that contributed to Washington’s success, the practical knowledge of Frederick the Great, or the scientific expertise of Benjamin Franklin.". So even then, 200 years ago, it was not practical for one single person to know about everything there was to know.
Samuel Gray
Samuel Gray on 19 Oct 2022
...yeah but it's not often in life that we begin to use a software program and are immediately granted Wizard Developer status.
This is more a consequence of the trend to advertize development packages as "easy to use and easy to master"/"Matlab for Dummies" and so on. You could say that the learning curve of Matlab is very steep...if you intend to master all of the commands and toolsets entirely? Yes it is very steep. If on the other hand you only use it to do what you need to do in order to complete your homework? Then it's not quite so steep, especially as your future homework will be limited by how well you have done your past homework. It may not be the best tool to use to complete your homework, which is why they are interested in your opinion about the software, but as far as learning how to operate the software in a more complex way, that's entirely between you and the Matlab documentation or whatever other training you take in order to learn those more complex uses. You have to put the time and effort in to learn. There's no way to just inject it into your brain.
Though perhaps Mathworks could consider developing an AI to help it develop better learning-tools.
Now that's an eye-opening challenge for the software industry.
Undoubtedly solved with some kind of computer-game, but that's life in the 21st century.
Anyway just be glad that your homework isn't to write your own version of Matlab from scratch in some "real" programming-language like Basic or C.
Alexander Moody
Alexander Moody on 21 Jul 2022
You can't unselect an ROI. You can select it just fine, but for some reason, the only way to unselect an ROI is to change roiHandle.Selected to false. I want to be able to click on a selected ROI and have it unselect.
Jerry Malone
Jerry Malone on 19 Jul 2022
Layer upon layer upon layer of unecessary abstraction.
I don't need abstraction. I need results.
Nowadays it's just easier and quicker for me for to write my own Matlab code than it is to use built-in object-oriented starndard library functions.
Example: I need an OQPSK constellation for a comms simulation. Writing the code to make it and plot it takes maybe 30 minutes max, and I understand and control every step along the way. The plots look like I want them to. I could try to figure out how to use comm.OQPSKModulation by doing a lot of Google searching, then trying to make sense of the once-excellent Matlab built-in help and look at the useless workspace where every object is 1x1 that tells me nothing, and then fumble around all afternoon trying to figure out what's a method, what's a property, and what's a parameter, and then get an ugly, mediocre plot with an unusable back background. Then I spend 30 minutes changing the background to white, getting the axes right, etc, but I lose all these settings so I have to it all over again a dozen times. What a waste of an afternoon!
Matlab used to be so much fun. Now it's turning into a nightmare. I'm starting to dread using it.
When I need abstraction, I use Java or C++. That's what Java and C++ objects are for. Matlab used to be a labratory, where I can test ideas quickly and easily, without abstraction or overhead.
Bruno Luong
Bruno Luong on 21 Jul 2022
The frustration is endless.
Rik
Rik on 21 Jul 2022
The main problem I have with your answer is that you posted it on this thread. This page is utterly useless on mobile, because the thread is too large. There is a big banner in the question explaining what to do. I would suggest deleting the answer here and continuing the conversation there.
Jerry Malone
Jerry Malone on 20 Jul 2022
Samuel,
The question was "What frustrates you about MATLAB". I gave an honest answer to that question, in hope that the MathWorks will consider my answer in developing new products. Ask an honest question, get an honest answer. I'm not complaining for the sake of complaining.
And this has nothing to do with "capitalism, etc. blah...".
I've been using MATLAB for over 20 years now. I used to love using it. These days I spend more time figuring out the convolutions and abstractions of OOP features than I do actually using MATLAB to get results. That should be a red flag warning to anyone at MathWorks: their product is no longer simple, nor is it intuitive.
Another case-in-point: just getting to this webpage took me several steps. Clicking on the email link provided took me elsewhere, and I had to search and click around to get here. That's not a good sign. Not simple. No longer intuitive.
Samuel Gray
Samuel Gray on 20 Jul 2022
Jerry, this reply isn't for you so much as for others reading it who are considering it seriously.
A) it's never good to complain about a "problem" that you can resolve with 30 minutes of searching and reading about online, that gets you through "what's a method, what's a property, and what's a parameter, "...to be specific...and with that information you can make use of methods, properties and (gasp!) parameters in Matlab and most if not all object-oriented programming-languages.
B) It's definitely not a good idea to spend an hour typing up a letter to complain about something that you can resolve, and learn, and grow as a programmer, in maybe 15 minutes online.
C) I understand why you think it was a good idea to do it anyway, because that often keeps people from complaining about things that shouldn't have happened in the first place.
...the problem here is exactly what is it that shouldn't have happened...
I do agree that the quality of the available documentation (and search-engine) does affect the time and effort spent in resolving this problem. That is, I would guess, precisely why Mathworks is trying to implement industry-standard solutions. So they don't have to write "Matlab" documentation that is largely separate from the whole body of OOP documentation available on the Internet.
D) capitalism, etc, blah blah blah.
ILoveMATLAB
ILoveMATLAB on 4 May 2022
Last fustration:MATLAB COMPLIER SDK implies MATLAB Advertisment.
If [blank] spends XX,XXX dollars extra to purchase the MATLAB Compiler SDK+ Required ADD ONS to export thier appliaction,[blank] should be able to replace the MATLAB icon with an icon of their choosing. Icons referes to the icons for figures and dialog boxes.
[blank] did not pay XX,XXX to advertise MATHWORKS
ILoveMATLAB
ILoveMATLAB on 5 May 2022
Rik, Thank you for the reminder I will repost.
Bruno Luong
Bruno Luong on 5 May 2022
What furstrate me more is MATLAB COMPLIER SDK is toolbox that XXX have to pay even if he/she has a license for a MATLAB compiler and MATLAB Coder. It's become so obvious (and ridiculuous) that TMW wants to make as much money as they can.
Samuel Gray
Samuel Gray on 5 May 2022
I love it when people use the word "should" as if things should actually be the way they think they should be. Despite the fact that they're not.
Suppose that Mathworks has an intern read through this chat and maintain a chart of changes to make based on such messages. Which one should they start with and how should they prioritize the work?
Rik
Rik on 5 May 2022
@ILoveMATLAB: I was not able to read either of your posts on mobile. Please post them on the second thread and delete them here.
ILoveMATLAB
ILoveMATLAB on 4 May 2022
LoL on the first link. I did't realize someone replied a couple of years later.
I tried the instructions in second link in 2019. The instructions change the installer icon for the runtime/DLL installer, but they do not change the icon in the dialog boxes and figures. When the end user runs the actuall DLL all, they see are MATLAB icons. It looks tacky. One incon is used for the installer, another icon is used for everything else.
Note I only have access to the compiler sdk/.NET builder up to 2019b. Did they change something since then?
Walter Roberson
Walter Roberson on 4 May 2022
ILoveMATLAB
ILoveMATLAB on 4 May 2022
MATLAB makes large projects difficult to manage.
Reasons
  1. OPP - No multi class files. This combined with the other issues prevent me from using ver the "Single-responsiblity Principle".
  2. Namespaces- No within file name spaces. No within file imports
  3. File Search: As of 2021a the in file search and cross file search is still a joke. there is no continuous search. This adds a lot of time to development. I basically use the current folder panel to jump between files. Also the search bar should be a panel like in most IDEs.
  4. Tab Completion: Originally the lack of good tab completion for python and MATLAB was attributed to the dynamic nature of the languages. Now python has Tabnine and Kite. Matlab has nothing.
  5. Function Input Hints: Spotty.
  6. Function Documentation when you hover with mouse over function:
  7. No Syntax code highlighting: At least highlight the MATLAB functions.
  8. No intellisence equivalent.
  9. I could go on.
I wonder if TMW could do thier C++ and Java coding without the above features.
ILoveMATLAB
ILoveMATLAB on 4 Jun 2022
Michelle,
If the opportunity is still available please message me.
ILoveMATLAB
ILoveMATLAB on 4 Jun 2022
Quick Update. My company finally gave me access to 2021b+. The editor is definitly impoved. This is a step in the right direction. Although, it did take me 30min to improve the font.
Rik
Rik on 10 May 2022
@dpb This answer was reposted to the new thread, where the spelling was corrected to OOP (object oriented programming).
Bruno Luong
Bruno Luong on 10 May 2022
@dpb you need to remove the dot at the end of the link
OPP, many suspects it's a typo of OOP, object oriented programming.
Persnonally I think MATLAB IDE is just fine.
dpb
dpb on 10 May 2022
<https://marketplace.visualstudio.com/items?itemName=Gimly81.matlab.> --> 404 Not Found
@ILoveMATLAB -- still don't know what OPP stands for??
Michelle Hirsch
Michelle Hirsch on 10 May 2022
Hey, it's Michelle here. I'm the head of the MATLAB Product Management team.
Thanks for taking the time to share so many of your insights on areas of MATLAB you'd like to see improved. I'd love chat with you to learn more if you are willing to carve out a little more time. I'll bring in some leads from the desktop and editor development team to make sure your feedback gets directly to the source.
Let me know if you are interested and I'll message you to arrange.
ILoveMATLAB
ILoveMATLAB on 4 May 2022
I understand most of your points. I guess MATLAB needs a new file extension with syntax that allow better OPP, tab completion, and syntax highlighting. I am tired of these band aid improvements.
However, I don’t care if editor accidently highlights a variable named bwdist, sum, or size because it thinks it is an official MATLAB function. It is a good idea to know that you are overshadowing an official MATLAB function in your code.
There is an unofficial VS Code plugin that highlights MATLAB functions. I don’t understand the reason TMW cannot add this feature. https://marketplace.visualstudio.com/items?itemName=Gimly81.matlab. .
Walter Roberson
Walter Roberson on 4 May 2022
Note: the editor changed as of R2021b. Some of the choices for the new editor were good; others are not so popular.
Function hints and tab completion were both improved.
Syntax is highlighted, already was before your release. All keywords are highlighted.
But as far as MATLAB is concerned, there is no such thing as "MATLAB functions" as different from user functions: the resolution of function name to implementation is done at run-time. There are some function names that can be resolved statically: names brought in by "import", nested functions, functions defined in the same file, functions for which there is already a definition in a "private" directory. But beyond that, name resolution starts getting dynamic according to the matlab path in effect at run-time. You can, for example, definitely create your own sum.m and if it is earlier on the path than the built-in sum.m then you will get your (or the third-party) implementation.
ILoveMATLAB
ILoveMATLAB on 4 May 2022
MATLAB keeps reinventing the wheel and does a bad job . The #1 rule of programing is never reinvent the wheel.
  • OPP: MATLAB OPP implementation is worse than all other well-known modern languages. Why? LabVIEW is actually worse but that is not a text based language.
  • Live Editor: Users wanted a Jupyter notebook like interface for MATLAB. Instead of creating an official stable feature rich plugin for Jupyter notebook, TMW released the live editor. I don't know how TMW could checked off/ released that product in 2016. (They probably ignored tester feedback) You did not need the end users’ feedback to know that it was too slow. The input lag made me feel like I was VNC’d into a computer oversees. Also, the execution time/ for loops….. I kept trying it from 2016- 2018. I have not touched it since 2018b.
  • Editor: I see a lot of complaints on the lack of modem IDE features. I agree. Before you create a new editor, I would recommend using an existing Opensource editor. I think it would be a good Idea to create a feature rich plugin for VSCODE.
Engineers always want to reinvent the wheel because it is more interesting, but it is not always worth effort. When TMW reinvents the wheel, it sometimes misses a lot of the qualities the made the original wheel great. This will overshadow the interesting features of the reinvented wheel.
Mike Croucher
Mike Croucher on 1 Mar 2023
Regarding Jupyter. MathWorks have now released a MATLAB kernel for Jupyter. Details at Official MathWorks MATLAB kernel for Jupyter released » The MATLAB Blog - MATLAB & Simulink
Steven Lord
Steven Lord on 2 Apr 2021
What do you mean by "change the size of a plot window"?
  • Change the size of the figure window
  • Change the amount of space in the figure window occupied by the axes
  • Change the limits of the axes to show a larger part of a plot that's larger than fits in the current view of the axes
  • (As a bit of a stretch) Change the width of the line or the size of the markers used to plot the line. [If you hadn't used the word "window" this would be a more plausible interpretation of your request.]
The plotting capabilities of MATLAB do offer a lot of functionality and with that must come some level of complexity. I will admit Handle Graphics does have a bit of a learning curve.
The main way I would recommend interacting with Handle Graphics objects is:
  • Find the handle of the object with which you want to interact. This could involve calling plot or other graphics function with an output argument, using the findobj or findall functions, or using the ancestor function.
  • Search the documentation for the task you're trying to complete to see if there's a function. Use axis or xlim to change the X axis limits, for instance.
  • Use dot notation to change the object's properties if there is no convenience function. f = figure; f.Position = newCoordinates; as an example.
One problem with your suggestion of "clean up this mess of features related to plot" is that the plot function has been around for at least 20 years (probably closer to 30 at this point) and people have written a lot of code that take advantage of those "mess of features". When we introduced the new version of the graphics system in release R2014b we did fix some long-standing bugs, introduced new capabilities, and eliminated or simplified some of the helper functions. Even though we tried to be careful about it and give plenty of warning, some users were still annoyed/upset with us for breaking their code. Doing a wholesale "blow up the system and replace it with something new" would be painful for both MathWorks and for long time users.
Allan Prince
Allan Prince on 2 Apr 2021
Why are the plot settings so difficult to find. For example, if I want to change the size of a plot window, I have to scour their webpage to search through each of a hundred different ways that plots can be modified. Many don't seem to be formally documented (at least not that I can find). They are embedded in responses to the help center and I have to read 50 of those before I find what I'm looking for.
I've had to create my own help center just to record all the features related to plot so I don't have to search for it next time I need it.
Something as commonly used as the plot feature should be quick and easy to use and it's worth their time to clean up this mess of features related to plot.
Martin Brorsen
Martin Brorsen on 27 Nov 2020
Compiled Matlab AppDesigner executables tend to forget functions when not used for some time
Samuel Gray
Samuel Gray on 21 Oct 2020
R2020b for Linux just wrecked my CentOS8 install.
It wouldn't install under my standard user account (needed access to /usr/lib and failed to get it) and then I tried to install it as sudo and that failed and then it wouldn't allow me to type anything in the email address text box when I tried it once more as a standard user. So I rebooted it and now it's throwing a dracut related error
".../etc/multipath.com does not exist, blacklisting all devices"
trying to shut down instead of completing startup and fails to do so then tries to start the GNOME Display manager and goes haywire. What fun. So R2020b for Linux is not compatible with CentOS8 after all I guess.
Note, these are problems just getting it installed and running...do you know how long it's been since I've had an installer break a working workstation Linux install to the point where it is unable to boot to the desktop? This is why Linux users prefer open-source tools and why network-admins prefer daily backups, networked user data directories and stock images! So, "Matlab on Linux" yay, "the Matlab installer breaking the Linux install and requiring a reinstall+reconfigure with a probable reformat and erasure of all user data on the partition" BOO!
[does this happen with Python and Eclipse? Hm...]
Luckily I have an Ubuntu install on the same drive and a good rescue usb key.
Now I just need to figure-out how to fix the CentOS8 boot process. No big deal.
Still, this is like Windows 98 all over again.
https://docs.centos.org/en-US/centos/install-guide/Rescue_Mode/
https://www.golinuxhub.com/2017/12/how-do-i-set-or-change-default-runlevel/
https://access.redhat.com/articles/754933
(this does not help as it siimply changes the display server not the desktop environment, which is corrupt,
and so the problem just has a different manifestation but the same source)
Rik
Rik on 28 Sep 2020
@John: I crossposted your comment to the second thread, please continue the discussion there. Feel free to post an answer there yourself. If you choose to do so, I will repost my comment to your answer and delete my answer.
John
John on 28 Sep 2020
Matlab should 'update' the new version instead of installing the new version. The reconfiguration is a nighmare because it's done only once a year or so. The extreme example is firefox, which updates once or twice a day. The users don't need to reconfigure anything.
At least matlab should provide a choice with every new version: new installtion or updating on existing version (and keep all configurations as is).
Bruno Luong
Bruno Luong on 29 Aug 2020
Personnaly I don't pay for MATLAB because of the community suppport. With few exception the document are mostly great that I rarely need to look elsewhere. Not sure it's the case of python.
dpb
dpb on 29 Aug 2020
Times have changed drastically and there's a lot more options out there now than were in late '70s and early '80s when Cleve invented MATLAB and wrote the first versions (in FORTRAN, no less!).
The PC version was introduced in December, 1984 -- that's now over 35 years ago; it's no wonder the syntax that has evolved from then doesn't necessarily match what might be used starting from scratch now.
tcl/tk didn't arrive until 1988, python first introduced in 1991 but didn't really take off until relatively recently.
Meanwhile MATLAB was solving real problems...it certainly saved me big time when in the consulting gig to not have to try to put all the pieces together that were in even the initial MATLAB-PC.
A brief history of matlab> for those who aren't aware is probably educational.
Walter Roberson
Walter Roberson on 29 Aug 2020
My memory seems to be coming up a bit short in bringing to mind any vendor that has unlimited community support?
So give us some benchmarks: What response time would you consider acceptable, and how complicated a question would be fair game?
For example if someone posts saying that they need the complete code for their honors project in robot surgery, automatic detection and excision of brain tumors in mice, then how much time would be fair to allocate before someone gave them the complete debugged and documented code ready to be handed in? (Because if complete code is not routinely provided in such cases, then that would only be limited community support, and you are specifically opposed to limited community support, so you are envisioning a community where every request for code is completely fulfilled.)
Furqan Hashim
Furqan Hashim on 29 Aug 2020
The cost of this software does not justify the time and effort you have to put in to get things going.
On one side you have a free of cost general purpose programming language (Python) that is easy to interpret and way faster than MATLAB. On the other hand you have an expensive software which would chew up all your RAM and make you write code that is difficult to debug along with a limited community support.
Take an example of group by in Python & MATLAB
Python:
df.groupby(by="a").sum()
MATLAB:
total = varfun(@sum, df,'GroupingVariables','a','InputVariables','b')
Would I pay and write extra lines of code?
Why would I pay for a tool that has a limited community support?
xingxingcui
xingxingcui on 11 Jul 2020
Deep Learning toolbox 2020a
A few months ago, out of personal hobby, I designed yolov3-yolov4's training and compatibility with the original framework. Overall, the matlab code implementation is still very concise, which is much more convenient than Pytorch and tensorflow, but there is also a problem. The differential framework is not efficient enough. For example, when GIOU is used as a loss, the network calculation loss is very slow and cannot be carried forward. Therefore, it is recommended that mathorks strengthen the improvement of the underlying performance and control the flexibility to facilitate the construction of various algorithms on the upper layer!
I personally have more than 9 years of matlab experience, I personally sincerely suggest that mathwork can currently make the following changes:
  1. Strengthen the interaction with other open source frameworks. Although there are onnx, caffe, and tensorflow, many of their operations are not supported, and it is completely impossible to customize import and export!
  2. The automatic differentiation mechanism imitates pytorch is very good, but the training efficiency is not as good as pytorch, and many matlab built-in functions do not support automatic differentiation;
  3. The custom network layer is not flexible enough, and the characteristics of the input and output cannot be customized;
  4. deeplearning toolbox There are too many official toolbox examples that use procedural programming, it is not easy to see the entire architecture, and a large number of cellfun functions are used. I think this function is not very readable. It is recommended to use high-dimensional array expressions as much as possible. In my open source yolov3-yolov4, the cefunn function is used as little as possible, dlnetwork is very inefficient in converting layerGraphy network!
madhan ravi
madhan ravi on 27 Jun 2020
The error message generated during a call to a specific function in a specific toolbox is misleading. If there’s an error message pointing that the toolbox is missing would result in quick solution.
madhan ravi
madhan ravi on 28 Jun 2020
Thanks Rik!
Rik
Rik on 28 Jun 2020
@Madhan: done. It probably should have happened way before the 100th answer.
madhan ravi
madhan ravi on 28 Jun 2020
That makes it very clear. I was mentioning about https://www.mathworks.com/matlabcentral/answers/555862-why-do-i-get-an-error-with-the-fit-function-even-though-i-m-following-at-matlab-tutorial . I hope somebody makes a second version of this thread. It takes a lot of time to load :( .
Walter Roberson
Walter Roberson on 28 Jun 2020
So complaining about missing toolbox is probably wrong.
What could use improvement in the case I describe would be if the stats predict() error message (especially about number of parameters) could mention the possibility that a different function was intended and give a link to a discussion of what might have been meant, similar to what I wrote up (link above)
Walter Roberson
Walter Roberson on 28 Jun 2020
In https://www.mathworks.com/matlabcentral/answers/427309-classify-requires-at-least-3-arguments#answer_445205 I discuss something similar to what Madhan is talking about (I think). However in that case, it is only possible to get to the wrong toolbox function if you have provided the wrong arguments for the function you wanted, or you called the wrong function for the result you wanted (such as calling predict() when your object needs classify()). Warning that a toolbox is missing wouldrrarely be correct behaviour in such a situation.
That is, suppose that you have a CNN and you want to call predict() for it but you got stats toolbox one because Deep Learning is missing. But you can only construct a CNN if you have Deep Learning, so missing DL would have been caught before.
You could have loaded a CNN, but if you did not have DL then load() would complain about the missing class and return a byte array. Byte array is not an error for the first parameter of the stats predict() so stats predict() should not be complaining about missing toolbox if it gets one.
madhan ravi
madhan ravi on 15 Jun 2020
I know this issue has been discussed before. But anyhow, it would be great to differentiate a function when its a symbolic function. It would avoid using multiple calls to subs(...). This process is extremely daunting when using langrangian approaches to analyse a system.
Illustration:
>> syms x(t)
>> diff(x^2,x)
Error using sym/diff (line 26)
Arguments, except for the first, must not be symbolic functions.
Presently the argument is requested as a symbolic function :(.
Christian Schröder
Christian Schröder on 4 Jun 2020
A few things that immediately come to mind ---
  • The student license only being good for one machine. I have a PC at home and a laptop I take with me to university; it would be nice if the student license could be used on two machines. (The regular personal license is good for three machines too after all.)
  • Toolbox prices. When you buy MATLAB you can get them at a substantial discount, but you don't know which ones you might need yet. When you know what you need you'll pay a lot more for them. Bit frustrating.
  • No support for hashes as far as I'm aware (structs aren't the same).
  • Strings, character arrays, cell arrays. Complex and arcane and prone to not behaving the way I invariably intuitively expect.
  • Explicit conversions, e.g. num2str and so on.
  • Explicitly having to squeeze() singleton dimensions from slices of multidimensional arrays, because e.g. matrix = some_array(:, 1, :) won't give you a 2D matrix.
  • Cleaning up plots and making them look good. The size of the resulting boilerplate often exceeds that of the actual plotting code.
  • Generally the relationship between and interaction of the various parts of a plot, which can give you a real headache if you're trying to do something that wasn't contemplated by the MATLAB developers.
  • print() and its issues with margins, paper size etc. Not an issue anymore in R2020a with exportgraphics(), though! :)
  • Indices always starting at 1. I almost always work with time series that start in t=0, and it would be extremely convenient to be able to have array indices starting at 0 as well.
  • Regular expressions feel tacked-on and not integrated into the language; there's no operators to match REs directly.
That said there's also a lot of things I like about MATLAB.
Steven Lord
Steven Lord on 22 Sep 2022
when I said "hashes" I meant associate arrays (hash arrays)
Release R2022b introduced the dictionary object that may interest you.
Christian Schröder
Christian Schröder on 5 Jun 2020
@Walter Roberson: containers.Map is associate arrays.
Thank you, that's useful to know.
Walter Roberson
Walter Roberson on 5 Jun 2020
The way that compose works by row is nice; the ways to get around the column behavior with fprintf() gets hacky if you need mixed data types.
dpb
dpb on 5 Jun 2020
Yeah, I go back so far that's all I think of w/ char() is the byte array. I also couldn't tell you when it did go to 16 bits. I get bit (so to speak :) ) by the forgetting of the extry byte on occasion when try to get too clever.
Yeah, strings have some useful features but they're not so useful for any string parts operations, much. Not sure why they didn't realize that from the beginning it would be needed for any general-purpose string class. Seems to me the fruit was just not quite ripe when introduced...whether there will be further enhancements guess will have to "hide and watch!". I do like some of the functions they introduced with them for higher-level extraction like the Before/After/Between family. They make for easy code even if performance may not be what alternative routes might be. compose is also handy on occasion.
Walter Roberson
Walter Roberson on 4 Jun 2020
char() arrays were all there were initially; they're pretty straightforward as just array of bytes.
If I recall correctly, they were indeed bytes originally. But it was many years ago that they switched to being "words" (16 bits)
The need to dereference substrings internal by "the curlies" {} is uncool,
I think the hypothesis is that if you stay within the string ecosystem that you never need to extract the individual characters. It doesn't work all that well in practice. string() objects are useful for some things, but not so much for analysis of individual characters, I find.
dpb
dpb on 4 Jun 2020
"Strings, character arrays, cell arrays. Complex and arcane and prone to not behaving the way I invariably intuitively expect."
char() arrays were all there were initially; they're pretty straightforward as just array of bytes. Inconvenient for much string handling owing to the need to explicitly address the full array (typically column count) indices and that are required to be regular/blank padded.
I don't find the cellstr() to be that arcane; it does take dereferencing in many places (altho that's gotten better by far in base functions now able to accept cellstr() besides char()). The biggest problem I tend to have is managing to recast the comma-separated list that occurs when use colon addressing. That's always been a pain to for me to remember from one time to the next.
string is confusing to me still, I agree. The need to dereference substrings internal by "the curlies" {} is uncool, indeed, and took me for some reason an inordinate amount of time to figure out--I kept expecting there to be a substr() function instead.
Walter Roberson
Walter Roberson on 4 Jun 2020
  • Explicitly having to squeeze() singleton dimensions from slices of multidimensional arrays, because e.g. matrix = some_array(:, 1, :) won't give you a 2D matrix.
That is actually a good thing.
>> A = randi(5, 10, 7, 2);
>> A == max(A,[],2)
10×7×2 logical array
ans(:,:,1) =
[etc]
>> A == squeeze(max(A,[],2))
Array dimensions must match for binary array op.
If automatic squeeze() were done, then to compensate, the implicit expansion operations would need some algorithm to match dimensions to figure out which automatically collapsed dimension is to be treated as the dimension to expand around. And that is going to fail in many circumstances. Such as if A was 7 x 7 x 7 and you did max() around a dimension and it was automatically squeezed, then the result would be 7 x 7, but MATLAB would not be able to figure out whether to expand along the first, second, or third dimension.
You do not want to have to introduce a 'squeeze', false name/value pair on any operation that could automatically trigger squeezing under your proposal. For example,
matrix = some_array(:, 1, :, 'squeeze',false)
max(A, [], 2, 'squeeze', false)
is just not going to be practical.
Walter Roberson
Walter Roberson on 4 Jun 2020
  • Regular expressions feel tacked-on and not integrated into the language; there's no operators to match REs directly.
This is historically correct. Regular expression processing is just library calls, as is the case for Python and R and C and C++ and Fortran and Java. MATLAB is not derived from AWK or Perl or Ruby. Or ksh or javascript.
Walter Roberson
Walter Roberson on 4 Jun 2020
  • indices always starting at 1. I almost always work with time series that start in t=0, and it would be extremely convenient to be able to have array indices starting at 0 as well.
You are confusing data value and index. Permitting index 0 on the basis that you start with t = 0 only makes any kind of sense if you permit indexing by floating point numbers, so that you could say MyTimeSeries(1.279e-3) to get the data associated with time 1.279e-3 . Your time series is rarely going to happen to be in seconds.
Walter Roberson
Walter Roberson on 4 Jun 2020
  • Explicit conversions, e.g. num2str and so on.
What about them?
Any implicit conversion, such as
"pi = " + pi
ans =
"pi = 3.1416"
is going to be unsatisfactory for some purpose. Too many digits, too few digits, only want the integer part, want it rounded / don't want it rounded, want bank format with commas between triples, want comma for decimal separator, number must be given in engineering format, number must be in full without exponential, left justification, right justification, positive numbers must have leading +, positive numbers must not have leading +, 0 must never be signed even if it is negative 0, must only have one space between elements, elements must be automatically aligned into columns with the width chosen according to the maximum magnitude...
It is impossible for implicit conversions to handle floating point numbers "correctly" because "correctly" depends upon the needs of the program.
Walter Roberson
Walter Roberson on 4 Jun 2020
The regular personal license is good for three machines too after all.
Not exactly. A full commercial license can be installed and activated on up to 4 machines, and can be used on any two machines simultaneously.
A regular personal license is also 40 to 80 times as expensive as a student license.
Walter Roberson
Walter Roberson on 4 Jun 2020
containers.Map is associate arrays.
Christian Schröder
Christian Schröder on 4 Jun 2020
Sorry, I should've been more specific --- when I said "hashes" I meant associate arrays (hash arrays), not hash functions in the sense of MD5 etc.
Rik
Rik on 4 Jun 2020
There are some FEX submission that will allow you to calculate an MD5 hash (and others).
The tricky thing with special data types like structs is that there might not be an intuitive way to linearize them, reducing the usefulnes of a hash to 0. I'm currently working on a function that will calculate a non-cryptographic hash without the need of a mex file (I created the algorithm myself, so it is probably vulnarable to every attack under the sun). I might implement a method that will unwind a struct if you're interested.
Walter Roberson
Walter Roberson on 21 May 2020
The recent changes that I know of with regards to importing xls data:
  1. A few releases ago, uiimport() started importing text as string() data type by default instead of character vector. The user has control over this in the tool.
  2. As of R2020a, readtable() and related functions now do an internal detectImportOptions() by default, which does a more thorough analysis and can result in different variable types, or can result in prefixes and suffixes automatically being detected. For example a field with a leading $ would previously have been considered to be a character vector, but now the $ might be treated as a prefix to be removed and the number imported as numeric. There is an option to turn off the default detection.
  3. Importing of time and duration data has been improved over the last several releases; in particular a field such as '13:42' would previously have been imported as character vector but would now be imported as duration. There is an option to control that.
Adam Danz
Adam Danz on 21 May 2020
@Sky, I feel your frustration. I commonly experience that during the early stages of learning new software. Having used Matlab, Python, and R, I think the gap between Python and Matlab is small. I'd bet that it takes less than 10 weeks of jumping into one after being familiar with the other before comfort levels start to match. R is another story and is least intuitive IMO. Another strength of Matlab is the documentation which is well formatted and largely consistent across all toolboxes. Once you learn how the documentation is organized, I find it very easy and quick to find what I'm looking for. Lastly, the community here is very helpful and if you can't find an answer to your questions in the forum, people are eager to answer new questions.
Sky Trader
Sky Trader on 21 May 2020
I tell you what irks me about Matlab: Everything. It is beyond doubt the most user unfriendly software I have ever used. The most simple tasks that you can do in other software, like importing data (used to be easy, not they've changed something and I can't even get apps to work on xls. data anymore), or installing an app is LIKE PULLING TEETH. Today I "simply" went to install an app I downloaded from there. But it's greyed out when you try and select it..... Then the "help" method suggested was to " Select "Add-Ons", and check that the Add-Ons install folder is writable." Of course there is no preference in "Add ons" that gives you this option. Typical....
Use Python, Use R, Use anytthing but this Matlabs app.
#BeyondFrustrating
Robert Kugler
Robert Kugler on 17 May 2020
Oh boy... where to start...
The biggest part is, its actually quite buggy, once you use it a bit outside the norm. I use it on ubuntu, for example... this combined with the usage of some of the not so widely used add-ons (like e.g. simevents) sometimes makes you think MATLAB tries to frustrate you on purpose...
No wonder python is taking over.
Samuel Gray
Samuel Gray on 19 Oct 2022
Yeah well obviously that's part of his complaint.
That it doesn't work flawlessly on all versions of Ubuntu, past, present and future, as, as well you know, the Mathworks developers main goal in life is to frustrate Ubuntu users.
Adam Danz
Adam Danz on 17 May 2020
Here are the Linux system requirements (r2020a)
If you scroll down to the Linux roadmap in the link below, you'll see that some Ubuntu platforms are not supported.
[SL: fixed typo]
dpb
dpb on 17 May 2020
"I use it on ubuntu, ..."
Is it a supported OS/version? (I "know nuthiink!" about that side, just asking....)
Adam Danz
Adam Danz on 17 May 2020
If the problems only happens under specific conditions, the problems might not be caused by Matlab. Matlab Online runs on a Linux system so at least that is ruled out of being outside of the norm. What errors do you have? What are the error messages? What conditions cause the errors? If you can validate your complaint, there's better chances that it will lead to improvements.
madhan ravi
madhan ravi on 11 May 2020
While MATLAB Online is a good feature there's still a factor that could be improvised for enhancing active collaboration on the cloud.
P.S: Made a feature request.
Andrew Janke
Andrew Janke on 14 Jan 2022
This is a cool idea. I have an outstanding feature request for a "Matlab Online Battle Mode" like this; TS case #03914156 if you want to pile on to reference that one in your request, too.
Octave Online has a feature like this where collaborators see a shared view of the Octave session, including the Editor and Command Window state, workspace, etc., and it's really useful for tutoring or remote collaborative debugging. Would be nice to see Matlab Online get a similar feature.
xingxingcui
xingxingcui on 23 Apr 2020
2、The deep learning toolbox and the outside world framework(pytorch、caffe、tensorflow...) can not be friendly support, such as onnx importer-exporter, this has been updated many times, but the performance is still very poor!
3、Since R2019b supports automatic differentiation in the deep learning toolbox, many low-level operations are still not supported, and complex networks cannot be built! Only a few examples provided on the official website are OK!
Hope the official development team is responsible!
xingxingcui
xingxingcui on 1 May 2020
  • For onnx, It should be onnx fine-grained to Operators, not rough "layer",For example, I customized a network layer yolov3Layer, how to export to Onnx?
  • How to control the network layer effectively and quickly? The input and output of the custom layer is very inflexible, you can see this column,The network input and output format is too dead for custom input and output control, and the properties of the class cannot be controlled!
[Z1,…,Zm] = predict(layer,X1,…,Xn),Must be in this format, and can not give developers free input and output!
Christine Tobler
Christine Tobler on 24 Apr 2020
We are actively adding support for more operations to the dlarray class. Are there any particular operations you have been missing?
dpb
dpb on 17 Apr 2020
Why can't MATLAB/TMW figure out to not open new figure default inside command window space so the next command to put on some amenities to the just-created plot occludes it fully????!!!!
You can set some random fixed location as a default, but that then is fixed so if you move the command window...
dpb
dpb on 23 Sep 2021
Yeah, it's not the focus of the command window that's the issue -- it's that the command window totally occludes the figure so you can't see what you're working on--and you can't even see a corner of the window to click on to get it to move it where you can.
Steven Lord
Steven Lord on 20 Apr 2020
Unless the new function has a KeyPressFcn defined, starting to type should automatically give focus to the Command Window. For example, let's make a maximized figure covering the whole screen.
figure('WindowState', 'maximized')
Now start typing "peaks" and the word, starting with the character p, should appear at the new prompt in the Command Window.
If we were to place the newly-created figure at some arbitrary location on the screen so as to minimize the overlap between the Desktop and the figure (it may be impossible to avoid overlap entirely, especially if one or both of the Desktop and figure are maximized) wouldn't that feel a bit like a game of Whac-a-Mole?
Rik
Rik on 17 Apr 2020
You could indeed use the defaultFigureCreateFcn to locate the main window and put the figure somewhere else. It is still klunky, but it might work well enough to keep frustration to an acceptable level. For a while I had the code below in my startup.m and a GUI template function.
try %#ok<TRYNC> if verLessThan is missing verLessThan would have returned true
if ~verLessThan('matlab','9.5')
% Use eval to trick the syntax checking in ML6.5 (both the ~ and
% the @ trip up the syntax checker).
defaultFigureCreateFcn=...
eval('@(fig,~)addToolbarExplorationButtons(fig)');
defaultAxesCreateFcn=eval(['@(ax,~){',...
'evalc(''set(ax.Toolbar,''''Visible'''',''''off'''')''),',...
'evalc(''disableDefaultInteractivity(ax)'')}']);
set(groot,'defaultFigureCreateFcn', ...
defaultFigureCreateFcn);
set(groot,'defaultAxesCreateFcn', ...
defaultAxesCreateFcn);
end
end
dpb
dpb on 17 Apr 2020
Yeah, being limited to those two is what is the beef... :( Neither all that satisfactory.
Might there be a way to execute a callback to check current command position (may not even be a way to determine that??) and then set the location by some relation to it?
It's just so klunky and irritating as is...
Or...another idea--is there a way to make it remain on top instead of being occluded?
Adam Danz
Adam Danz on 17 Apr 2020
When I'm using just a laptop monitor, I often dock all figures using the line below. I use this 'favorite' shortcut to toggle on/off figure docking for future figures.
set(0,'DefaultFigureWindowStyle','docked')
When I'm using a dual monitor, I'll set the default figure location far from the Matlab command window using
set(0, 'DefaultFigurePosition', [x y w h])
I'm sure you're already aware of these commands but that's how I handle the problem.
dpb
dpb on 14 Apr 2020
Inconsistency in names for Name-Value Pair arguments in new functions of similar purpose and name.
Since inception which predates R2006a when TMW began the feature of incorporating version of introduction in the "See Also" section, textscan set precedent with 'HeaderLines',n to skip n lines at beginning of file. Then readtable came along in R2013b and used same name. All's well and good. That's some 15+ years of history and learned behavior.
Then some wise guy gets the idea with readtimetable in R2019a to change the same meaning to 'NumHeaderLines',n. Now we've got two names for the same thing and who can ever get it first go to remember who's who in the zoo? All the new functions like readmatrix, readcell and friends use new.
WHY!!!??? All it does is cause typing errors and forces correction or waiting on the interminable time for tab completion to load its module only to not see the name in the displayed list because too far down and the trained 'h' response of course fails to find...
All in all makes wonder what code design reviews must focus on to let these inconsistencies propogate.
And not to get started on the myriad of overlapping functionality of nearly redundant functionalities in lieu of updating existing...
dpb
dpb on 14 Apr 2020
Yeah, I forgot to add those use cases as well...intended to but phone rang and got distracted, forgot where was!:
I'm not surprised about the time frame but the mind boggles that stuff like this doesn't get hit on hard by those using those trial releases. I've not been on any early prior to public releases until that very last one by which it'd be too late, anyway.
I just can't imagine how this level of stuff gets past the very first code internal review session...seems like it should be a design criterion to keep absolutely as close to existing style, nomenclature and naming as possible and an act of Congress to violate.
Guillaume
Guillaume on 14 Apr 2020
"I wonder if new functionality is tested between or within development teams"
I don't work for Mathworks and I can't go into details due to NDAs but from the few glimpses I've seen of the development process it can take years for a new feature to be released, going through several rounds of testings including with customers.
Guillaume
Guillaume on 14 Apr 2020
'NumHeaderLines' was introduced with detectImportOptions much earlier than 2019b. I also always get tripped up by this.
Guillaume
Guillaume on 14 Apr 2020
"A related gripe: barring a few exceptions you will have to dig through the release notes to unearth when a syntax was introduced"
I raised that as an enhancement request a few years ago: at the end of the doc, together with the "introduced in xxx", also have "option yyy added in zzz".
I was told it would add too much to the documentation!
Adam Danz
Adam Danz on 14 Apr 2020
I wonder if new functionality is tested between or within development teams. You'd think that if a between-team review were implemented, these kinds of inconsistencies would be flagged.
The datetime format inconsistancies between various functions also drive me nuts.
A step in the right direction is the new OnOffSwitchState value that replace the on/off/true/false dichotomy.
Rik
Rik on 14 Apr 2020
A related gripe: barring a few exceptions you will have to dig through the release notes (for base Matlab and every toolbox separately) to unearth when a syntax was introduced. Sometimes it's even a 'hidden' change, documented nowhere else I could find, like the change in imclose in R2017a: link. (although now I check, it seems they did add a comment at the bottom of the doc starting in R2019a)
At some point I considered creating my own system that would scrub the website doc or pdf doc and compare the documented syntaxes. Turns out creating a test suite and just trying still works best.
J. Alex Lee
J. Alex Lee on 9 Apr 2020
On the topic of functions and their interfaces, it used to be that I wished Matlab had a way to easily do default values for optional arguments, and named arguments...but the arguments block is a pretty welcome addition, which addresses default values, and I've taken to the key/val argument methodology that works well. But it is frustrating that original Matlab had lots of ad hoc "argument parsing" so that you had a "flexible" interface...I guess you can call it convenient, but it often means more doc/help look-ups for me to understand how to correctly specify arguments...legend() is one that gave me a lot of trouble recently. Can't be helped at this point though, I guess.
Walter Roberson
Walter Roberson on 9 Apr 2020
I know that some people find it frustrating that functions do not look for variables in their calling environments, so if for example you have
function y = f(x)
and you execute f by clicking on the green run button, that it will not look in the base workspace to find x.
Walter Roberson
Walter Roberson on 9 Apr 2020
(Regular functions cannot capture values the way anonymous functions do.)
Image Analyst
Image Analyst on 9 Apr 2020
Arushi, I find function very easy to execute. You just call the function by name passing it whatever arguments it requires. At least if they're a regular function -- anonymous functions can be a bit cryptic but you don't have to do it that way (you can always do it as a regular function instead).
You might explain your annoyances in a new question in more detail and we'll try to give you tips on how to do it.
Arushi Bagga
Arushi Bagga on 9 Apr 2020
Not able to execute functions easily. Such an annoying issue
Asif
Asif on 23 Oct 2019
I hate how add-ons aren't available for student or home license holders. For example, why should the HDL coder and verifier add-ons require a massively expensive professional license?
BGranato
BGranato on 30 Sep 2019
The fact that some of the code I wrote a year ago doesn't run on the new version of MATLAB. I need to write the MATLAB version in each file I make...
The fact that if I want to update to the newest release of MATLAB, I need uninstall the current version (it takes too much space).
The fact that I can't do GPU computing unless I have NVIDIA GPUs (don't know if this has changed).
The fact that live scripts look great but are really slow.
The fact that examples are not friendly for new users or people who are not familiar with the topic in question.
The fact that I can't create an environment with older versions of MATLAB to run my older code.
The fact that free languages (e.g. Python, R) give me seemingly equal amount of support and aren't super expensive.
The fact that help foo will print 800 lines when I just wanted to remember the order of inputs
dpb
dpb on 1 Oct 2019
I wonder about the disk space issue being real or just perceived...these days of humongous drives on most systems wouldn't see like there would be much of an issue. In the olden days when 10 MB was huge, that wasn't the case.
Image Analyst
Image Analyst on 1 Oct 2019
Really? You can get equal support for free with Python? You can call someone on the phone and get a live person within 2 minutes that will go over your code with you, and even setup a webex with you and drive your computer if needed? What Python phone number is this?
Walter Roberson
Walter Roberson on 1 Oct 2019
The fact that if I want to update to the newest release of MATLAB, I need uninstall the current version (it takes too much space).
Trying to use some kind of cross-linking to existing files sounds like a good idea, but in practice it ends up being a horror show of incompatible libraries. We see that happening a lot on Linux releases of MATLAB.
Walter Roberson
Walter Roberson on 1 Oct 2019
The fact that some of the code I wrote a year ago doesn't run on the new version of MATLAB.
That is not common at all for MATLAB, unless the code was written using features that the release notes (and sometimes warnings) say will go away soon. I will not say that it does not happen, but Mathworks has been pretty good about giving a year of advanced warning.
However, if the code you wrote a year ago was for a Mathworks release that was not current at the time, then Yes, that can happen: Mathworks does not always give more than a year of notice.
Walter Roberson
Walter Roberson on 1 Oct 2019
The fact that help foo will print 800 lines when I just wanted to remember the order of inputs
Increasingly, and much more advanced in Live Script, when you start typing in the function name, MATLAB's editor will pop up showing you the arguments available.
Walter Roberson
Walter Roberson on 1 Oct 2019
The fact that I can't do GPU computing unless I have NVIDIA GPUs (don't know if this has changed).
That is unlikely to change any time soon. There are too many competitors with incompatible GPUs. OpenCL is not the solution: it permits too much variation to be able to get good performance without per-model-line optimization. And NVIDIA has a large start over AMD in libraries such as Deep Learning.
If I recall articles correctly, the current battle in the GPU market for Deep Learning is between NVIDIA and IBM, with IBM concentrating on a different kind of Deep Learning algorithm, using GPUs that are not compatible with AMD or NVIDIA.
In the consumer market, Apple will not support OpenGL or OpenCL in their new OS to be released any day now. Most of Apple's current desktop and laptop offerings are based on AMD, but they have been creating their own GPU for years that will be specialized in supporting their proprietary METAL graphics protocol; the family has already been introduced in some of their hand-held products and is expected to be put in a fair range of their products (but not everything) starting Spring 2020. Apple's GPU is not compatible with AMD or NVIDIA (or IBM).
Walter Roberson
Walter Roberson on 30 Sep 2019
The fact that I can't create an environment with older versions of MATLAB to run my older code.
Could you expand on that? You seem to indicate that you do not have the disk space to support such a feature if it were available.
Lucas Rhode
Lucas Rhode on 8 Sep 2019
I may be biased from my OOP Java background, but what bugs me the most is the poor OOP support. Anyway, here are my thoughts in detail:
  • The IDE: no decent code highlighting, no methods/class refactoring, no way to find where your function is being used, no concept of projects until R2019 (which is shitty since it will take a decade for everyone to migrate) and god forbid you try to handle a multi-class application. Since there's no code highlighting and types are dynamic (and there's no way to point out the type you'll be using on a variable) it gets >ugly<.
  • One release per year is too much for a programming language (although I do understand that it is not meant to be a programming language in the classical sense of developing and mantaining long-term projects).
  • Poor handling of paths/namespaces: It can be very annoying to keep track of MATLAB's path; what bugs me in particular is the fact that you need to import everything IN EVERY SINGLE METHOD instead of one import for the whole class. Also the "+" folder names are dumb (pardon my french)
  • Again about the IDE: you need to explicity tell MATLAB what arguments your function accepts (c'mon mathworks, we know you can do better than that)
Lucas Rhode
Lucas Rhode on 30 Sep 2019
I'd like to say that I adopted the .empty "pattern" in my applications and it works like a charm. Also I recently found out that classes support type definition like
object myLib.myPackage.MyType;
and that's VERY helpful.
Adam
Adam on 10 Sep 2019
I would tend to agree that all the original points made are indeed annoying, but I've just learned to get used to most of them. I've been programming heavily in OOP in Matlab for I guess 7-8 years now, learning more and more as I go, and the things you mention have all annoyed me at some point (I come from a C++ background originally). As Stephen pointed out though, types of things are often not known until run time so highlighting is difficult from this perspective.
However, I have noticed that in more recent versions Matlab has become a lot more intelligent understanding what certain objects are. Often I have done a Ctrl D, or right-click open on a function attached to an object, just in pure hope and have been very pleasantly surprised that Matlab was able to take me to the correct class function. This definitely was not the case a couple of years ago, so it is able to do some kind of behind the scenes analysis of the code, but still not entirely, of course.
The highlighting issue always showing just 'object' essentially is very annoying. I guess I've just got used to keep opening the code file to see the arguments or opening help.
OOP was a bolt-on to Matlab though, some years ago, in a language that was never designed for it. It has improved plenty over that time, but for an OOP purist Matlab will never be the language of choice as it has other greater priorities for supporting. I have noticed that the speed of OOP implementations has improved notably over the last few years too, although there are still pitfalls for using designs that may be perfectly sensible in other languages, but don't behave well in Matlab.
So I do agree with all the points, and would love OOP to be constantly improved, but as with all my Matlab learning since I started I've tended to just mould my own ways of working around the Matlab language, especially since my forays into C++ are very rare nowadays (and Java pretty much never). Loading packages or package functions into every function they are used in rather than just into a class itself is one of the reasons I make relatively little use of packages though.
On the subject of empty variables, in an OOP way of working I tend to declare things with a specific type of emptiness wherever possible, to avoid unpleasant surprises (errors, usually!) from a variable trying to be expanded from a double to something else, e.g.
myVar = myClass.empty;
Mostly, I also do it to act as documentation within the code too - making it clear what the variable should be.
Walter Roberson
Walter Roberson on 10 Sep 2019
we rarely use a variable to store more than one type of value
In my experience, that is not the case, that it is not uncommon at all for the same variable to be used for different types.
In particular, it is common for variables that are going to grow to be initialized to [] which is the empty double precision matrix, and then to have the actual data type assigned into it in a later step. For example,
Features = [];
ThisFeature = min(ImageArray);
Features = [Features; ThisFeature(:)];
Image arrays are typically integer data type, so the above code likely has Features changing from double (the empty array) to (for example) uint8 (because min() of uint8 is uint8)
Most people treat [] as a typeless empty array, but it is 0 x 0 double.
Lucas Rhode
Lucas Rhode on 10 Sep 2019
And yeah, i understand that because of the dynamic typing variable highlighting is hard but we rarely use a variable to store more than one type of value, thuussfore an idea: some markup that allows you to tell the IDE what the variable is
Lucas Rhode
Lucas Rhode on 10 Sep 2019
yeah, my mistake, correcting myself again: when using classes, since the first argument is the reference to self, the tip tends to show only this first argumentUntitled.png
Stephen23
Stephen23 on 8 Sep 2019
"...Having different colors for variables, methods, functions, etc. would make everything easier to read"
Keep in mind that in many cases they are only resolved when the code is run, not statically.... so would you prefer a colored-as-function that turns out to be a variable when the code is run?
This could occur when a directory is changed, or with evaluated strings, etc.
"...the tip it shows when you press tab doesn't even has the name of the arguments the function expects - unless you explicitly tell MATLAB what to show..."
If you wait half a second after writing the opening parenthesis, you will get this pop-up:
Capture.PNG
It is not the same as the tab completion, but it requires nothing extra on your behalf.
@Rik: that is not tab completion, which actually involves the tab key:
Rik
Rik on 8 Sep 2019
I still don't see what you mean by your last point. I see the input argument names for my function in the editor and in the command window:
Untitled.png
For a file with this header (and no functionSignatures.json trickery):
function data=readfile(filename)
Lucas Rhode
Lucas Rhode on 8 Sep 2019
Let me correct myself:
  • Almost no syntax highlighting = no colors used. Having different colors for variables, methods, functions, etc. would make everything easier to read
  • The last note refers to the fact that the tip it shows when you press tab doesn't even has the name of the arguments the function expects - unless you explicitly tell MATLAB what to show...
Rik
Rik on 8 Sep 2019
Some nitpicking:
  • There is function highlighting (at least for local functions), unless you're using eval and friends, in which case you have only yourself to blame.
  • There are actually 2 releases a year: the a and b release are not hierarchically different.
And can you explain your last note about the IDE? I'm not sure I understand. It seems pretty reasonable that you need to tell Matlab what arguments you expect. You have the flexibility with varargin if you need that. It certainly is a lot better than languages where you have to declare input type and scalar/array.
per isakson
per isakson on 20 Aug 2019
Background
While experimenting with a function, which I had downloaded from FEX, I encountered the error
No such file or directory
After having looked too long for the cause in the wrong places I realized that my writing permission had disappeared. Currently, I haven't a clue why.
>> [fid,errMsg] = fopen( 'cssm.m', 'wt' )
fid =
-1
errMsg =
'No such file or directory'
>> [fid,errMsg] = fopen( 'cssm.m', 'rt' )
fid =
3
errMsg =
0×0 empty char array
Googling for "windows 10 folder read only" showed that I'm not alone.
Frustration
The poor message, 'No such file or directory', fooled me. Something like 'No writing permission' would have been more helpful.
per isakson
per isakson on 20 Aug 2019
"come from the OS" yes it does.
Good to see that the OS sometimes gets the message right.
Guillaume
Guillaume on 20 Aug 2019
Win 7, R2019a, I've just tried to create a file in a folder for which I do not have write permissions and I get:
>> [fid, errmsg] = fopen('cssm', 'wt')
fid =
-1
errmsg =
'Permission denied'
In any case, wouldn't the error message come from the OS rather than matlab?
Rik
Rik on 11 Jul 2019
You shouldn't be using inline anymore to define anonymous functions. Also, posting your question in English on its own thread increases your chances on getting an answer. Have a read here and here.
Valentina Compagnucci
Valentina Compagnucci on 11 Jul 2019
NO ENTIENDO COMO DEFINE LA FUNCION
En este caso, la fuente de tensión es constante Vcc=10V y las condiciones iniciales son:
(0)=
Definimos f (función que representa el comportamiento del circuito) con el comando inline:
>> f=inline('[u(2);-2/2*u(2)-1/4.56*u(1)]','t','u')
f =
Inlinefunction:
f(t,u)[u(2);-2/2.4*u(2)-1/4.56*u(1)]
Luis Ruiz
Luis Ruiz on 2 Jul 2019
With the Legacy Code tool two dimensional arrays cannot be used, and that is very frustating as matrices are part of the core of MATLAB.
yunhui zhou
yunhui zhou on 28 Jun 2019
Does not support GPU computing on AMD GPU.
Also a relevant question is whether Matlab contains optimized math libraries for AMD CPU.
Steven Lord
Steven Lord on 22 Sep 2022
Walter Roberson
Walter Roberson on 28 Jun 2019
It turns out that OpenCL is a loose enough framework (too many optional features that are not consistently implemented) that it is difficult to optimize for except by targeting one vendor and one model of gpu. Nvidia cuda on the other hand is quite good about compatibility.
Mathworks has been unable to obtain the AMD optimized math library equivalent to intel math kernel library.
Rik
Rik on 28 Jun 2019
It is not totally my field, but as far as I'm aware there isn't really a serious alternative to CUDA, which only works on NVidia GPUs.
I would be amazed if Mathworks wouldn't have put in some effort on optimizing for AMD CPUs, but I expect most of the optimization is simply having a multi-threaded option, which should then have similar performance on AMD vs intel.
They don't hate AMD, but they just have a huge product stack, meaning it is slow to move. I expect Mathworks to optimize for the hardware their customers are currently buying. Since the market share for AMD has been relatively small, it makes sense that any vendor-specific optimization would not be AMD.
Vladimir Bondarenko
Vladimir Bondarenko on 24 Jun 2019
Still, no syntax highlighting for the reserved words false and true:
isBool = true;
wouldMatlabTellYou = false;
Viet Dai
Viet Dai on 7 Mar 2022
@Walter Roberson in most languages, true and false are reserved words. Why don't matlab follow the majority?
Vladimir Bondarenko
Vladimir Bondarenko on 24 Jun 2019
Fair enough.
Walter Roberson
Walter Roberson on 24 Jun 2019
false and true are not reserved words. They are functions like zeros and ones and nan
Vladimir Bondarenko
Vladimir Bondarenko on 24 Jun 2019
With each new release, the Help browser becomes slower and slower.
In 2019a, it takes jaw-dropping 30 secs to open the Contents page. Contents page, Karl!
Moreover, in earlier releases when a help page eventually was loaded its scrolling was relatively smooth. But 2019a took it further and changed scrolling to jumping.
Otherwise great stuff. Love it.
Adam
Adam on 24 Jun 2019
Couldn't agree more. The help is, on the whole (certain toolboxes maybe less so!) excellent, but the help browser is dreadful.
A simple
doc rot90
on my command line the other day caused Matlab to freeze up for 10 minutes for no apparent reason. I ended up manually killing off all 10+ jxBrowser Chromium processes.
Matt J
Matt J on 21 Jun 2019
blkdiag does not return the result in sparse form, or provide an option to do so. I am puzzled that this wasn't an obvious use case just by the very nature of how many zeros a block diagonal matrix will typically contain.
The workaround is to pre-convert all arguments to sparse type, but I have to believe it is a lot slower than a better optimized blkdiag could be.
args=cellfun(@sparse,{a,b,c,...},'uni',0);
B=blkdiag(args{:});
Jan
Jan on 24 Jun 2019
Prabhakaran thirugnanam
Prabhakaran thirugnanam on 15 Jun 2019
I faced a problem when I try to automatically connect the simulink subsystem in large quantitiy.
At one situation when I try to add the blocks using the command add_block(BlkPath,'position',[X1,y1,x2,y2])..... I got the error saying that The position should be <=32767. But Infact I've around 1000 subsystems to be connected one below the other. SO obviously it'll exceed 32767. I've no solution other than creating multiple layers which is actually taking more effort.
TADA
TADA on 5 Jun 2019
The implementation of properties. They are class fields, and they are the accessor methods to these fields, (get/set). This duality leads to confusing and unexpected behaviour and at times performance issues.
Just take a look at this code:
classdef ClassA
properties
PropA;
PropB;
end
methods % property accessors
function value = get.PropA(this)
% yes, from within the method
% barring the same name you
% access the property with
% the same name. Confusing...
value = this.PropA;
end
function this = set.PropA(this, value)
% thanks for pointing out Adam :)
this.PropA = value;
end
end
end
They have built-in set events (which you have to love) but only if the class derived from handle (which I understand but it can be confusing).
But for the love of God, none of these complex mechanisms can be overridden in derived classes
TADA
TADA on 5 Jun 2019
What do you mean by in/outside the class? That could be a possibility for decorators. Still I would prefer traditionally overriding them, in my experience overriding subsref and subsasgn is a big pain
Matt J
Matt J on 5 Jun 2019
You can always overload subsref and subsasgn to morph the effects of dot-indexed refs and assignments outside the classdef. I don't see why you would ever want to overload their effects inside the classdef. That seems very bug prone...
TADA
TADA on 5 Jun 2019
@steven, I don't disagree on the principle, but your example is taking the principle to the extreme - preventing a completely acceptable practice to prevent misuse.
Besides, the same can be said about methods, if I were to implement the number of sides validation in a separate function for the purpose of reusing that bit of code, the validation method can still be overridden by a deriving class still violating the same principle.
On the other hand, this inability to override properties makes it impossible to use the decorator design pattern on classes not developed by me for example, or If I use your shapes example, If I want to add a Equilateral triangle class which inherits from triangle, and I want to enforce the sizes of all sides and angles to be identical, I can't if the original validation was done in the property setter.
Steven Lord
Steven Lord on 5 Jun 2019
Rik: the method get.<propertyName> is not the same as a method named get. You can't directly call the property accessor methods as stated in the first Note on this documentation page. If you try to query a property that has a corresponding property getter method, MATLAB will call it. If you try to assign to a property that has a corresponding property setter method, MATLAB will call it. There are a few exceptions listed on this documentation page (for setters) and this one (for getters).
If you want a get method that can retrieve any of the properties of your object, you could subclass one of the SetGet mixins or you could write a simple get method using dynamic referencing. If this is a method of your class it has access to protected and private properties, so be careful. You could be more sophisticated by querying information about the property metadata but that's an advanced maneuver.
function value = get(obj, propertyName)
try
value = obj.(propertyname);
catch ME
% Handle the error somehow
% You could check ME.identifier and do different things
% depending on the ID
% You could turn the error into a warning then
% return NaN or [] as the value
% You could return some sort of useful default
% You could simply rethrow() the error (though for this you could
% just omit the try/catch block.)
end
end
As for overriding property accessor methods in subclasses, let's say you had a Shape class. That class has a property numberOfSides with a property setter that ensures numberOfSides is finite.
Now you try to create a subclass of Shape called Circle. You can approximate a circle as a regular N-sided simple polygon (for a large value of N) but you decide you want to go to the limit and have Circle's numberOfSides property be Inf. [It's a bit of abuse of notation, but go with it for purposes of this example.] If Circle could override Shape's numberOfSides property setter to allow Circle's numberOfSides to be Inf you would have a Shape (a Circle isa Shape) that's not a valid Shape. That would be a Bad Thing, violating the Liskov substitution principle.
TADA
TADA on 5 Jun 2019
@Rik, to use get/set functions you need to either implement the get method like you did or inherit one of these classes:
The thing is when you implement the get/set methods for properties, the runtime will call them instead of retrieving the property value, properties in matlab are both the field and the access methods which is confusing in my oppinion (in C# they are completely different notions and in Java you simply have no properties, so you have to implement the get/set methods and keep a relevant naming convention - both C# properties and Java get/set methods are completely overridable by the way, while the members aren't).
Also, if im not mistaken, there is some caching of the property so the get method isn't called each time the property is accessed unless this is a dependent property
so, when you do some calculation in the get/set method, to keep it clear and prevent future mishaps, I think it's best to declare the proerty Dependent:
properties (Dependent)
PropA;
end
in that case the interpeter will enforce you to implement the get method too which is good
TADA
TADA on 5 Jun 2019
offcourse the access methods are unnecessary in this particular example, they just come to show the confusing syntax (where you set the same name as the funciton), but that's not important
Thanks for pointing out that i forgon to return "thirt". As I almost never use value classes, I always forget
the main issue in my oppinion is not being able to change property functionality, like you said I always end up with a bunch of protected methods for that, but that can't be done if you inherit some builtin class or a third party class... I don't see why it should cause problems to override get/set methods, as they are basically regular functions with a unique naming convention.
As for the pass-by-ref being defined by the class rather than the variable, it's similar to other managed environments such as Java and .Net
I believe it has to do with the no pointers thing, so the runtime has to know where to allocate your variable (heap or stack). I can see how that would be annoying for someone with a background in c++. I come from .Net so pointers are the devil in my mind ;)
Rik
Rik on 5 Jun 2019
So in principle you could make get return a value that is not actually the property value:
function value = get.PropA(this)
% yes, from within the method
% barring the same name you
% access the property with
% the same name. Confusing...
value = 10*this.PropA;
end
Maybe this is because I hardly ever work with classes, but shouldn't this work?
>> get(a,'PropA')
Error using get
Cannot find 'get' method for ClassA class.
(I also had an mlint warning that the set method should return the object)
Adding the function below solves the error, but doesn't return the property value, but instead calls the get.PropA method. Now I'm confused as well.
function value = get(this,prop)
if strcmp(prop,'PropA')
value = this.PropA;
else
value = NaN;
end
end
Adam
Adam on 5 Jun 2019
Coming from C++ it was initially a learning curve for me to get used to some of these aspects for especially value classes, but I'm not sure I understand what the issue is here or what your suggestion would be for improvement.
In this example your get and set functions are totally un-necessary as the default ones (which do exist for value classes) do exactly as yours do (you are missing the return 'this' from the set function, which I also usually forget on the rare occasion I write a value class).
The get and set functions allow you to add extra functionality beyond simply setting or getting a value if you so wish (e.g. most obviously I do validation of the input type in a set, but rarely write a get except for dependent properties). The function syntax using the property name makes perfect sense to me, otherwise how else should it be named to be less confusing? You can ignore it totally if you want and write your own functions named
getPropA
setPropA
as you might in C++, but it seems rather un-necessary.
Derived class behaviour is an annoyance certainly. I end up doing a bunch of protected functions of the
doSetPropA
type that are over-ridden in the derived class which works fine and is just more coding. I would imagine that if derived classes were able to over-ride the get and set methods of base class properties this would cause a whole load of other issues that would need workarounds.
There are certainly aspects of Matlab class programming that seem very clunky, but I've got used to most of them now. The lack of constness, coming from C++, is the one that gets me the most, as well as the idea of pass-by-reference being defined at class level rather than for individual objects, even though I've done almost no C++ programming for over 5 years.
Peter
Peter on 31 May 2019
What annoys me most is that every time we update to a new version I have to go back and fix up all my scripts to be compatible with a new release.
I'm beginning to wonder why we bother paying for updates.
Just switched to 2019a and all the Database Toolbox things I had been using in every version from about 2013b through to 2018b don't work anymore and I have to go back and re-code everything.
To say nothing of the fact that I'm still fighting with the Help hang on start-up and the fact that jxbrowser has some mysterious error that keeps throwing exceptions.
I should really go and buy something that actually works!
Steven Lord
Steven Lord on 10 Mar 2022
The Code Compatibility Analyzer app introduced in release R2022a may be of interest to you.
Bruno Luong
Bruno Luong on 5 Jan 2021
Just one more missing combination to go. Go go TMW, you can do it! lol
zmi zmi
zmi zmi on 5 Jan 2021
lol, seems like they found a new answer in R2018b, R2020b
strncmp('a', 'b', 0)
strncmp('a', 'b', 2)
ans =
logical
1
ans =
logical
0
Walter Roberson
Walter Roberson on 31 May 2019
Jxbrowser is not the most stable of programs. It is not uncommon for several stray processes to be left running when I exit matlab (Mac)
Jan
Jan on 31 May 2019
strncmp('a', 'b', 0)
strncmp('a', 'b', 2)
% Matlab 2009a:
false, false
% Matlab 2011b:
true, true
I do not undestand, what could be casted to a char here.
Steven Lord
Steven Lord on 31 May 2019
Peter: have you contacted Technical Support directly for help with the issues you described here?
To say nothing of the fact that I'm still fighting with the Help hang on start-up and the fact that jxbrowser has some mysterious error that keeps throwing exceptions.
If not, I recommend doing so. You can use the telephone handset icon in the upper-right corner of this page to contact Support and work with them to determine if there is a solution or workaround for those issues.
Steven Lord
Steven Lord on 31 May 2019
Jan: I tried those two lines of code in a couple releases between R2010b and now (R2010b, R2012a, R2015a, R2018b, and R2019a) and the result was two true values in each of those five releases. [By the documentation that first should have returned false. I'll report that.]
Ah, now I see. You said this behavior changed after R2010b, but in fact the behavior changed in R2010b, and I suspect you're missing a pair of curly braces. The results of:
strncmp('a', {'a'}, 0)
strncmp({'a'}, 'a', 0)
strncmp({'a'}, {'a'}, 0)
did change in R2010b as the result of a bug fix. See Bug Report 629110. The documentation was reformatted or revised in release R2017a and information clarifying exactly what should happen for n = 0 was added at that time. I'm not sure why that information wasn't added in release R2010b.
Rik
Rik on 31 May 2019
I don't have an old release installed on this machine, and I can't find in the documentation what the behavior should be in either case for R13 (6.5) or R2010a. The R2019a doc explains your examples should return false and true, respectively. What was the (undocumented) prior behavior?
Also, the strong typing of this function is a bit uncharacteristic for Matlab. You could of course simply cast to char, but that might lead to strange behavior for values like 0.
Jan
Jan on 31 May 2019
@Peter: "I should really go and buy something that actually works!"
Yes, I agree with this. Unfortunately I do not know a programming language as powerful as Matlab with a better compatibility between the versions. I can run 99% of my Matlab code written in release 5.3 in 1999. Some difference have been brute, e.g. that the behavior of this has changed after R2010b:
strncmp('a', 'a', 2)
strncmp('a', 'a', 0)
and this was not mentioned in the documentation or the release notes.
Nevertheless, that only reliable way to have a stable programming platform is not to change the platform. You are paying for the updates, but it is your decision if it is a benefit for you to install them.
Adam
Adam on 31 May 2019
I ended up with some accidentally when I initialised a variable as [] and then later assigned a graphics object to it via indexing and because [] is technically a double, that was the class of the array so graphics objects assigned to it were automatically down-cast to double, which was an unpleasant discovery. Nowadays I use the gobjects function to initialise such arrays!
Rik
Rik on 31 May 2019
RE: get/set: I haven't actually ever needed to cast to double before using get/set. The closest to such a conversion I have ever come is my maximize function (and to be honest, I don't recall why that conversion was necessary, maybe some function gave an error on a non-numeric input, but I haven't documented that).
Adam
Adam on 31 May 2019
In a general case backward compatibility with Matlab releases is excellent (though there are obviously some cases, which you have encountered where it needs more work) and I have only found a handful of releases since R2006 when I started using Matlab that have caused me to do any kind of serious upgrade work. Most of that involved the major graphics update where backwards compatibility was either not always possible or even where it happened I didn't really want it (e.g. even now you can have graphics objects cast to a double and use them with the old get/set style and they'll work, but I don't want that in any of my code).
The Help I agree is full of suspicious bugs with jxChromium. I've had countless weird issues happen with it, freezes, etc as well as the fact that the Help processes aggressively lock files they have no business locking (or at least they did in a recent version, I haven't checked in R2019a)
Walter Roberson
Walter Roberson on 31 May 2019
The four database toolbox functions that were removed in R2019a were set to trigger warnings in R2018b, and their demise was indicated in R2018a release notes.
The number of releases of warning that Mathworks gives about future removal of functions varies a fair bit. For example Symbolic Toolbox warned for several years that the ability to sym('an expression') was going to go away, but finally provided a replacement for it in R2017b with a warning that it was going away in R2018a, which did indeed happen. A lot of lead time in concept, not so much lead time in practice.
yunhui zhou
yunhui zhou on 20 May 2019
Matlab forces regular users (not license administrators) to install update release within the software, and hide the direct download link of offline update package since release R2018b.
What's worse, I have found the direct download link by myself, and had posted them somewhere in this post to help people suffering from the awful update process, and Mathworks removed my answer.
Mathworks, why do you think updating within the software is recommanded?
Samuel Gray
Samuel Gray on 19 Oct 2022
"Matlab forces regular users (not license administrators) to install update release within the software, and hide the direct download link of offline update package since release R2018b."
...trust me, that is NOT the case in our shop. Quite the reverse.
Walter Roberson
Walter Roberson on 31 May 2019
Do you have a date and time estimate of your post? There is a log I can examine but it is very very large and I would have to do a lot of clicking.
There is not much on this site that Mathworks actively monitors, though some of the individual employees happen to read this thread for ideas.
Historically it would be more likely for one of the volunteer moderators to clean up posts. The only thing that we are actively asked to look for is people being abusive, but they do appreciate our trimming out copyrighted material posted without permission, and material about cryptography which there are legal restrictions on.
Yunhui Zhou
Yunhui Zhou on 31 May 2019
I have posted the link in this topic (also in the link you provided), verified by a couple of browser refreshes within a few hours, and then over one night my entire answer disappeared. I did not give up and write this answer again.
My guess is that Mathworks actively monitor this thread and remove any information that they do not want us to know. But certainly I have zero evidence of my guess and would like to know the actual reason.
Walter Roberson
Walter Roberson on 31 May 2019
I did not see you post the link in this present topic, and unfortunately finding any information about that in the activity history is a pain unless there is a fairly good time estimate.
yunhui zhou
yunhui zhou on 19 May 2019
  1. Mathworks hides the direct download link for update release since Matlab R2018b, and force regular users (not license administrators) to update the software by clicking the bell-shaped button within the software.
  2. I cannot use Matlab anymore when it is downloading the update release.
  3. The download speed from my lab to the Mathworks's server is awful.
  4. I have serveral Matlab installations (same version) to maintain in my lab, and without an offline update release installation package, they all have to download the same update package and go through this awfully long update process. I have no idea why the Mathworks thinks updating within the software is the optimal experience.
Solution for anyone suffering from this:
The update package for Matlab R2018b can be directly downloaded at: https://www.mathworks.com/downloads/web_downloads/show_updates?release=R2018b
The update package for Matlab R2019a can be directly downloaded at: https://www.mathworks.com/downloads/web_downloads/show_updates?release=R2019a
yunhui zhou
yunhui zhou on 19 May 2019
Please officially support rotating axes labels to align with axes angle in 3D plot. The workarounds in FEX does not always provide optimal results.
William Katzianer
William Katzianer on 31 Jan 2019
Code Generation for HDL (or C) through a Simulink block.
The ones index works fine in Matlab, but it has no place in code generation software. Why is it that I have to use an artificial index (starting at 1), only to have it to subtract 1 anyway to use the zero's index? I'll show you an example that left me extremely frustrated with how the HDL Code Generation works:
x = Table(counter); // Matlab based
Now the HDL that compiles is...
x_temp <= x(to_integer(counter -1 ));
And I've noticed that this bug occurs in many other places that involve embedded development. It's artificially inflating the cost of said function for no reason other than to maintain compability with the original simulation environment.
This is extremely bad logic handling and has lead to an index-1 bug that I spent days trying to figure out.
I shouldn't have to start my counter at 1 in order to get the table indexing to properly work. Matlab should be able to differentiate between simulation and code generation (where it's obvious I want a 0-based index). The price is so outrageously high to begin with, this kind of thing should be flawless.
Birk Andreas
Birk Andreas on 13 Nov 2018
I think it is a shame that one has to buy a third party toolbox to use state of the art multiprecision (see https://www.advanpix.com/documentation/users-manual/#Symbolic_Math_Toolbox_VPA_vs_Multiprecision_Computing_Toolbox). Clearly, vpa is not an option for large-scale numerical computations (it is really awfully slow, se also: https://nickhigham.wordpress.com/2017/08/31/how-fast-is-quadruple-precision-arithmetic/). If I understand correctly it should at least be possible for Mathworks to include freely available libraries like this one: https://www.mpfr.org/. Mathworks, can you explain why this has not happened so far? If I look into the list of software which already uses MPFR I ask myself: Why not MATLAB?! How pathetic! Mathworks should be embarrassed! And please, Mathworks, if, on one glory day, you implement it, put it into the Standard MATLAB license! Don't be so greedy to take extra money for yet another toolbox which should be state of the art these days!
Sorry, for the harsh words!
Samuel Gray
Samuel Gray on 19 Oct 2022
...um, Matlab does not do everything and anything that anyone would want to do with it.
Much less for free.
I realize that this is a huge problem for some, but hopefully they will learn to manage their expectations.
Pavel Holoborodko
Pavel Holoborodko on 19 Nov 2018
The irony is that MATLAB already does reference counting for each mxArray, keeping track of all the assignments, destruction, etc. It would be great if they would just allow us to register callbacks for major events happening with our custom objects (assignments, free, increasing/decreasing ref counter would be the best, etc.).
Potentially I can do this by installing hooks for some internal MATLAB functions (by DLL injection) but this is far beyond any maintainability and portability.
Walter Roberson
Walter Roberson on 19 Nov 2018
I was thinking there would be uses involving reference counting but I did not want to be "putting words in your mouth". Also I was concerned that the parameter copy behavior might perhaps make the reference counts inaccurate, and I was concerned about how to properly handle reference counts for variables captured by anonymous functions, and how to handle persistent variables and how to handle destruction by ways other than assignment .
Pavel Holoborodko
Pavel Holoborodko on 19 Nov 2018
This is needed when we want MATLAB object to hold only pointer to some data (e.g. pointer to C++ class instance created in MEX). This way we can use MATLAB object only as a thin interface to fast C++ functionality - mexFunction just retrieves the pointer and everything else happens in C++ without any copy-overhead (e.g. getting properties of MATLAB object from MEX, etc.)
In this scenario assignment operator and destructor are needed for reference counting - to keep track of used C++ objects and to do the garbage collection on unused ones. Ability to overload these functions are standard feature of any OOP language. This would allow huge performance boost for MEX/toolboxes.
Here is my old post with more details: https://www.advanpix.com/2013/07/19/undocumented-mex-api/
P.S.
Handle objects have destructors but they are designed to share one unique resource - like serial port communication or similar.
On the contrary, we need these features for usual objects which hold (point to) different data, like multiprecision numbers.
Walter Roberson
Walter Roberson on 18 Nov 2018
"Allow overloading of assignment-without-subscripts operator (e.g. A = B). At least partial overload."
Could you describe some use cases for that?
Pavel Holoborodko
Pavel Holoborodko on 18 Nov 2018
And here is my few cents on what should be improved in MATLAB (from point of view of third-party toolbox developer):
  • OOP: Allow non-handle classes to have it own destructor.
  • OOP: Allow overloading of assignment-without-subscripts operator (e.g. A = B). At least partial overload.
  • MEX: Argument copy overhead is terrible, allow us to acces the raw data directly.
  • MEX: Do not disable undocumented functions in MEX which we are using to overcome the MEX API slowness (e.g. mxGetPropertyShared). Yet better make them well documented and public.
  • MEX: Please inform about upcoming changes to MEX API before releasing them, not post-factum.
  • MEX: Please make MEX API thread-safe.
  • OpenMP/C++ RT: Please outline the roadmap when MATLAB will switch to new OpenMP version, C++ RT, etc.
These are the most essential points only.
Pavel Holoborodko
Pavel Holoborodko on 18 Nov 2018
Disclaimer: I am author of Advanpix toolbox you mentioned.
MPFR is just an arithmetic library. Its inclusion to MATLAB will not provide any advanced functionality automatically - fast and parallelized matrix computations (dense, sparse), optimization, numerical methods, special functions, even basics like array manipuilation, etc.
All these functions require lots of efforts and years development in order to support multiprecision properly (with guaranteed accuracy, multi-core CPU support, etc).
Also this would require changes in MATLAB's internal architecture, because it was designed for standard floating-point types of fixed-size.
In this light, third-party ready-to-use toolbox seems to be a good solution for TMW so far. We have already done most of the work after ~10 years of dedicated development. Why not just use our toolbox then :)?
TADA
TADA on 11 Nov 2018
Binary files!
It's ok when you save your data as a binary file for better performance, but GUI layout should not be a binary file.
Here's a small scenario I'm sure you're familiar with: You change the structure of your packages, or a file name and
BOOM
none of your GUIDE figures work. with a text file, you can find/replace it, but good luck with .fig files.
And App designer is not better, I built an app on R2018a, now I have R2017b, guess what? no backwards compatibility. and I don't mean if it works or not, some of the features are missing, NO, you simply can't open the project and view your own code.
TMW, it's time to join the rest of the world and start using markup for GUI layout.
Samuel Gray
Samuel Gray on 19 Oct 2022
"GUI layout should not be a binary file."
That's an interesting statement. Care to defend it authoritatively?
"TMW, it's time to join the rest of the world and start using markup for GUI layout."
I guess that I'm not part of "the rest of the world", then, because I've never heard of 'markup' much less used it for GUI layout. Can it be used to calculate the FFT of a sequence? Does it even have a Github page?
Adam
Adam on 13 Nov 2018
Nowadays I often find myself just using GUIDE like a design tool. I lay out my components to remind myself what I want then I just do a programmatic GUI myself (not an auto-generated one) using the GUI layout toolbox. I'd hate to do it without that though, positioning all the elements absolutely. The downside is the layouts are slow though so there is a delay in GUI creation.
TADA
TADA on 13 Nov 2018
Still I must admit that some days I feel I'd rather solve a differential equation using CSS than develop a GUI using GUIDE
TADA
TADA on 13 Nov 2018
Sounds good, Ill have a look.
Jan
Jan on 12 Nov 2018
The tool https://www.mathworks.com/matlabcentral/fileexchange/20152-guidegetter converts a .fig file into Matlab code, which creates the figure.
I'm using GUIDE for finding a nice layout of the UI elements. Afterwards the guidegetter extracts the positions and I'm happy with creating the rest programmatically.
Rik
Rik on 12 Nov 2018
I just tested it, it is indeed unidirectional and the creator function isn't even that bad in GUIDE terms.
Adam
Adam on 12 Nov 2018
I seem to remember seeing that somewhere too, but I don't think it is bidirectional so if you want to make changes again you can't just do them in the nicer WYSIWYG form, you would have to edit the programmatic code, which is sure to be far worse than anything you would write yourself as a programmatic UI!
Walter Roberson
Walter Roberson on 12 Nov 2018
I seem to recall that guide has an option to generate code to create the gui instead of using a fig file.
Adam
Adam on 12 Nov 2018
I tend to mix and match GUIDE and programmatic UIs depending on my requirements, but when I use it GUIDE does what I expect and doesn't give any major dramas, except for the problem mentioned by this answer, which is also obviously a real pain for teamwork with a revision control system. Even when others aren't working on the same GUI I often find GUIDE is asking me to save changes when I don't remember making any changes. Of course I can try Undo to work out what said change was, but usually I just decide I'd better save it to be sure because I can't just run a comparison for changes in my RCS.
Programmatic GUIs don't have this problem, but I use them mostly for complex GUIs so they always involve a lot of programming. Part of that is because I take advantage of it to write reusable components though (something else you cannot do in GUIDE) which obviously takes more time and effort than just throwing a single-purpose GUI together as one unit.
App designer is unusable in numerous ways though so I don't go near that except an occasional experimental UI to see what is new in a new version before I inevitably rage quit and go back to GUIDE or programmatic UIs!
Walter Roberson
Walter Roberson on 11 Nov 2018
Visual placement of design elements is typically much easier to get something approximately right than working it out from code. Unfortunately that "approximately" turns out to be too inflexible and not to scale well.
Rik
Rik on 11 Nov 2018
It is the Apple method done wrong. (The Apple method being "It works, yay, don't ask how, I won't tell you.") It start breaking the moment you leave the confines of GUIDE itself. The second input of callback functions have been implemented for years now, but GUIDE still adds a comment saying the eventdata is reserved for later implementation.
For myself GUIDE made me think that GUI design in Matlab was very difficult, so it rather held my projects back.
TADA
TADA on 11 Nov 2018
I read in Yair Altmans blog that under the hood, app designer is basically html and JavaScript. Which is a tiny step in the right direction. But if that's the case why we can't just write html and JavaScript is beyond me...
Stephen23
Stephen23 on 11 Nov 2018
"Meanwhile, people are still mostly encouraged to use GUIDE."
I also have no idea why this is. I have written hundreds of GUI's, and right from the start wrote them all myself. After reading the GUIDE-related threads and reading the long obfuscated GUIDE code attached to them I am very glad of that decision!
As the saying goes, GUIDE seems to be a solution in search of a problem...
Rik
Rik on 11 Nov 2018
My personal gripe in this context is that GUIDE is horrible (IMHO) and AppDesigner is not a good successor because it has a totally different philosophy. It is not an update, but a complete make-over.
Meanwhile, people are still mostly encouraged to use GUIDE. I have written a small guide to avoid GUIDE (pun intended) that I sometimes post on this forum. I always use a function instead of a .fig to create my figures. For repeated buttons it is even easier than using manually created buttons.
Matt J
Matt J on 29 Oct 2018
My junior assistant ran tests against solver in excel and found that it gets better results, takes less time to get there, and is less prone to local optima than these two functions
If the Excel solver is avoiding local optima non-accidentally, then it is an apples-to-oranges comparison. It likely means your junior assistant is running fmincon and fminunc against the evolutionary/genetic solver in Excel. The fair comparison would be to run Excel against ga from Matlab's Global Optimization Toolbox.
Alexandra Beaven
Alexandra Beaven on 29 Oct 2018
The fmincon and fminunc functions are not great. My junior assistant ran tests against solver in excel and found that it gets better results, takes less time to get there, and is less prone to local optima than these two functions. Annoying because I am a BIG Matlab fan and have no intention of rewriting 25 years of optimization code in another langauage (I am under pressure to rewrite in Python).
Alec Poulin
Alec Poulin on 27 Sep 2018
I don't know if these points were said in one of the 128 answers, but these frustrate me:
  • Pressing Tab on the keyboard writes four white spaces instead of an actual tabulation character. It's usually not a big deal, but I need to press on the arrow keys more often to move horizontally in a line;
  • When I want to see the value of a variable in the console, it prints it with to much space around. For example, Matlab prints this:
>> x
x =
12.8000
But any of these would be as clear and more concise:
>> x
x =
12.8000
>> x
x = 12.8000
>> x
12.8000
It's really annoying when I want to print the value of a variable in a loop and I rapidly loose sight of the older values because the newer values take so much space in the console.
Samuel Gray
Samuel Gray on 19 Oct 2022
...doesn't your PC come with the Calculator app?
You know, you can call that from within Matlab.
Alec Poulin
Alec Poulin on 27 Sep 2018
It doesn't seem to stick. Earlier today, I used the command format compact, closed Matlab and reopened it, but the extra spacing was back. Steven's solution worked, thanks!
dpb
dpb on 27 Sep 2018
It also "sticks" automagically between sessions...
Steven Lord
Steven Lord on 27 Sep 2018
In the Command Window Preferences you can change the "Numeric display" option in the "Text display" section.
Alec Poulin
Alec Poulin on 27 Sep 2018
I didn't know about that, thanks to you two!
Is there a way to make the compact format the default one?
Steven Lord
Steven Lord on 27 Sep 2018
For your second point call format with the 'compact' option. If you need to revert back to the default line spacing use the 'loose' option.
dpb
dpb on 27 Sep 2018
Set
format compact
to eliminate the extra blank line on console. format
Alec Poulin
Alec Poulin on 27 Sep 2018
Aaah... :) I didn't know for the tab. I looked for something related to this in the preferences, but I guess I didn't see it. I just found it now. Thanks!
For the second point, I usually use disp or fprintf, but just writing the name of the variable would be simpler.
Adam
Adam on 27 Sep 2018
Tabs as spaces is in preferences, unfortunately one that is on by default. I always turn it off though.
You can workaround the second point with sprintf easily enough, but it is true it does take up a lot of space by default.
Harvey Rael
Harvey Rael on 3 Aug 2018
Has anyone tried to measure angles between a huge amount of vectors, by engineering convention?
My first vector I need to measure against 180 other vectors, and obtain the angles between them all. Once MATLAB gets to 180 degrees, it starts measuring DOWN from 180, instead of up. Similar thing happens at 360..drives me barmy!
Added to that it gets some angles simply wrong, so any post calculation manipulation to the angles also gets done wrong, so I need to decipher which ones have been done wrong and do post-post calculation manipulation. Now imagine that for 180x40 array of angles. For feck sake MATLAB!
Stephen23
Stephen23 on 3 Aug 2018
@Harvey Rael: please ask a new question about this.
Mireia Torralba
Mireia Torralba on 17 Jul 2018
The figures are very slow (much more than they used to be, I find new versions are worse than previous ones). Also, clearing the desktop or packing does not really free memory allocated by Matlab, at some point is always necessary to close the program for freeing memory occupied by Matlab.
Walter Roberson
Walter Roberson on 17 Jul 2018
Whether deleting MATLAB objects really frees memory allocated by MATLAB depends upon the MATLAB version and operating system version. For example on IRIX, it did not release memory to the OS, but in the same time frame, on MS Windows it did release memory to the OS.
Adam
Adam on 25 May 2018
A minor irritation, but still a bit annoying. Matlab's editor is obviously very lacking when it comes to refactoring tools and other helpful features like that, but surely this could be made easier:
MLint helpfully tells me my syntax is not recommended and tells me what to use instead, but then I have to manually make the change because there is 'No Autofix Available'. Surely this is the easiest of easy autofixes to include?!
Adam
Adam on 18 Jul 2018
"Actually I think the name is misleading because someone might think it tells you whether the string is actually a folder/directory anywhere on your computer, and it doesn't do that. For that you want tf = exist(folder, 'dir')"
What does it actually do? I know its usage is not recommended anyway so it's a moot point, but I still have it in various places in my old code. The help says it finds directories on the 'search path', but as I understand it the 'search path' is what you get by typing 'path' on the command line (which, on my machine, appears to be exactly what I have in the 'Set Path' dialog, which is just folders that contain code files), yet I just tested isdir out on a few folders/directories that are definitely not on that search path and it still returns true.
I have actually been using the 'exist' approach too at times, but use of isdir has never thrown up any problems for me previously.
Stephen23
Stephen23 on 18 Jul 2018
"Where do I find the "Contact Us" button?"
At the top of every page of this entire website.
Image Analyst
Image Analyst on 18 Jul 2018
You can find a link for that on their web site, or send an email to support@mathworks.com. Or scroll to the bottom of the help for the isdir function and click the No button to the question "Was this topic helpful". Someone will read it.
Actually I think the name is misleading because someone might think it tells you whether the string is actually a folder/directory anywhere on your computer, and it doesn't do that. For that you want tf = exist(folder, 'dir')
Jeff Miller
Jeff Miller on 18 Jul 2018
Jan, sorry, a dumb question: Where do I find the "Contact Us" button?
Jan
Jan on 25 May 2018
Do not let this detail frustrate you. Use the "Contact Us" button and submit an enhancement request. I'm sure, Mathworks will consider it in the next release.
Alex Bogias
Alex Bogias on 15 May 2018
Arrays of structures for Stateflow.
Matlab and Simulink support this but not Stateflow. Using pointers is the only workaround that gets around this.
hlk
hlk on 11 Apr 2018
What infuriates me most about Mathworks products are the inconsistencies in the user interface. They also neglect to respect a number of UI conventions of Windows or software in general. This includes but is not limited to (some) dialog boxes not accepting Enter for "Ok" and Escape for "Cancel" or not changing button focus via LeftArrow/RightArrow, missing navigation abilities in the "Current Folder" view via Alt+LeftArrow/Alt+RightArrow, missing search-by-letter abilities in the "Workspace" view, having to mouse click before scrolling via MouseWheel (no mouse hover), missing support for 4th/5th mouse button aka navigation buttons. These issues have been reported to and discussed with support in 2014 (Case Number 00931154) but still remain.
Adam
Adam on 12 Apr 2018
I rarely use or know keyboard shortcuts, but inconsistencies in function interfaces do frustrate me, especially plotting functions in different toolboxes. Most plotting functions (maybe all) in base Matlab allow you to specify an axes as the parent and return an object that you can tweak settings on, but there are still plotting functions in other toolboxes that give no such flexibility and just insist on launching a new figure or only work embedded in a tool.
dpb
dpb on 11 Apr 2018
Amen, brother!!!! And it seems to be getting worse and worse on the inconsistencies. I have previously commented that competition amongst various development teams to introduce new features as fast as possible appears from the outside somewhat like SNL cast teams/members competing for air time with no longer a real top-level direction and sense of a cohesive overall product style.
We've had multiple iterations of the table starting with the Stat Toolbox dataset version that was supplanted shortly thereafter by table in the base product; meanwhile the other still hangs around for historical and compatibility reasons because folks used it then but it's now added to the exceeding "code bloat" of stuff...these things should, in my view, wait until there's a coherent long-term forward plan instead. Just one of many possible examples.
Aditya Deshpande
Aditya Deshpande on 3 Apr 2018
What I find very annoying sometimes is MATLAB's indexing. It starts from 1. With that in mind, there is no way to easily differentiate between functions and array elements, as both user round brackets.
Walter Roberson
Walter Roberson on 5 Apr 2018
When you concentrate on array indexing compared to function call, then you are concentrating on implementation.
Most often, implementation is not important. What is typically important is what is sometimes known as the "interface contract": that if you do this operation it will have a result that has such-and-such properties.
For example, the representation of complex numbers changed completely in R2018a, but unless you are calling an external routine you will probably never notice. The details of a sliced-crosswise-only-on-Tuesday complex implementation don't matter, except at interface boundaries: it just matters how the object behaves.
You can see this in the change to most "system objects" a couple of releases ago, where calling ObjectName(parameter) was made equivalent to calling step(ObjectName, parameter) . Is ObjectName(parameter) indexing? Is it a function call? It doesn't matter: you mostly only care about how the result is defined.
Walter Roberson
Walter Roberson on 5 Apr 2018
Adam:
In MATLAB, array indexing is a function call. See https://www.mathworks.com/help/matlab/ref/subsref.html . On my system the function is /Applications/MATLAB_R2018a.app/toolbox/matlab/ops/subsref for the basic types.
Adam
Adam on 5 Apr 2018
I agree with the original point about it being annoying to have the same syntax for functions as for array indexing (though not in relation to indexing from 1, which I like and is independent of this), but I have got used to it.
It isn't about wanting to be able to do gymnastics with the language and mix and match the same name for a variable and a function call in the same statement, more just a simple readability thing. Looking at a line of code (or even a few lines) it can be impossible to know whether a statement is a function call or an indexing into a variable without either trying to open the 'thing', if it were a function, or scroll up the code to see where it was previously used if it is a variable.
It's not a massive issue, especially if you keep functions short, but Matlab is also a scripting language and we have all probably had to deal with scripts hundreds of lines long at times (either our own or from someone else). Code should be as readable as possible and being able to see at a glance whether something is a function call or array indexing ought to be a part of that.
Walter Roberson
Walter Roberson on 5 Apr 2018
"The point was making is that one can have SUM() as a function and an array independently"
No you cannot.
program testfun
implicit none
INTEGER :: sum(6)=(/1,2,3,6,7,8/)
print *, sum(sum)
end
The total of the elements is 27. The function prints out
1 2 3 8 0 0
which is using the contents of the vector as indexing into the vector and not complaining about index out of range.
If you add your own integer function named sum to this, then that function will not be called: use of the name as an array overrides looking for it as a variable.
If you use a different variable name but add your own function named sum, then that function will not be called: the intrinsic overrides.
If you try to create a function and an array with the same name, then unless they happen to have the same type then fortran will complain about the clash.
So... array and function of same name: error if they do not have the same data type, use as array wins if they do. function of same name as intrinsic: intrinsic wins.
dpb
dpb on 5 Apr 2018
"FORTRAN" is now officially "Fortran" per ISO (F90).
I don't have an interpretation at hand but am pretty sure any compiler that confused GOTO as a variable with a computed GOTO would be considered broken officially. However, as of F90 it is marked by Standard as an obsolescent feature altho virtually all compilers will still continue to support it for legacy code (altho also most have a compiler switch to check for standard conformity).
Didn't say SUM is a keyword; it's a transformational intrinsic function but it's immaterial which/whatever it is.
The point was making is that one can have SUM() as a function and an array independently and it's not limited to whether the function name happens to overlay a keyword or an intrinsic; it's a general feature of the language that everything is interpreted by context rather than keyword-matching.
All I was doing was pointing out the difference between Fortran as a compiled language vis a vis what Cleve chose to implement in the Matlab interpreter even though it started out in FORTRAN (I'm not sure which he dialect was used initially; it may be mentioned in some of his historical musings but I didn't go look again just now).
The biggest change in syntax/interpretation/compilation was introduced in F90 with free-form source with which blanks became significant; through F77 and still with fixed-form source, blanks are also irrelevant--
DO i = 1, 7
and
DOi=1,7
are entirely equivalent in F77/fixed source format.
Walter Roberson
Walter Roberson on 4 Apr 2018
SUM is not one of the statement keywords of fortran; https://link.springer.com/content/pdf/bbm%3A978-1-4612-2562-1%2F1.pdf
Walter Roberson
Walter Roberson on 4 Apr 2018
In FORTRAN, using Goto as a variable name would get confused with a Computed Goto if the variable were indexed in some contexts.
dpb
dpb on 4 Apr 2018
A) Is Fortran rule; Cleve chose to make the interpreter easier so didn't follow the pattern. In Fortran a statement keyword is part of the syntax of a statement such as WRITE, IF, or DO. Unlike many languages, in Fortran keywords are not reserved; the compiler recognizes them solely by their context. So, a program can have an array named IF, read, or Goto (although one hopefully would have enough sense to not actually do such). Hence, however, having a function SUM() and a variable SUM is perfectly legal and while perhaps confusing to the human reader, won't confuse a correct Fortran compiler nor do anything else ugly like alias the supplied/builtin intrinsic function of the same name with the variable (although one can shadow/replace INTRINSICS with one's own version if desired).
Walter Roberson
Walter Roberson on 3 Apr 2018
Consider the circumstances under which you need to want to differentiate between indexing and function invocation:
A) A user has created a variable named "sum" and wants to be able to index that variable, but at the same time expects that sum() will invoke the function that does totaling. That is, the user wants the same name to refer to two different objects, one object being a function and the other being a vector, with no connection between these except for the name. Is this a good idea? Because if it is a good idea then I ought to be able to say,
function total = test(sum, sum)
total = sum(sum[1..5]);
because if I can have the same name for a function and an indexed variable in a system in which function handles can be passed around, then I should be able to use choice of () versus [] to indicate which of the two versions of the name I am referring to.
This has nothing to do with whether indexing starts at 0 or 1.
B) You have an array of functions and you want to be able to differentiate between invoking each element of the array in turn on a set of arguments, compared to indexing into the array. Currently, if fun is a vector of function handles, then does fun(3) invoke each member of fun with argument 3 or does it index to extract the third element of the vector?
The answer in MATLAB at present is that you cannot have a vector of function handles, but that you can have a cell array of function handles, so you can use fun{3} to extract the third entry of the vector. There is no syntax at present to invoke each element of the array with a given argument, except to use arrayfun(@(F) F(3), fun) or equivalent.
The ambiguity is not completely gone in MATLAB: it is possible to use the Symbolic Toolbox to create an array of symfun. If you manage to do so, then it is not possible to index the individual elements using MATLAB syntax, and () indexing invokes the symbolic functions with the argument(s) given.
This has nothing to do with whether indexing starts at 0 or 1.
C) You define an internal representation for an object in which for some reason it is reasonable to index the representation and it is also reasonable to invoke the object as a function, and you are frustrated that different syntaxes are not provided for those two operations, forcing you to define different object methods that clearly differentiate between the two. For example you might be building a transfer function using the four-matrix representation and you want indexing by the matrix number to return one of the matrices but () to apply the transfer function, but cannot, forcing you to dire workarounds like obj.C to return the matrix well known in control literature as the C matrix instead of being able to force the user to remember whether the C matrix is obj[3] or obj[2] (the matrices are traditionally laid out in a 2 x 2 grid. Gosh it's rough to have to provide clarity of meaning!
This has nothing to do with whether indexing starts at 0 or 1
D) You are interfacing to a representation of a C++ or similar object and want to be able to access one of its internal properties by indexing without invoking the object, and you happen to know the deliberately-obscurely documented object lay-out (which means that you know exactly which compiler and compiler version was used, since the object layouts among the major C++ compilers are deliberately made incompatible to avoid the possibility of accidentally linking between objects with different internal representations.) This is something that even the compilers themselves do not do except at quite low levels, preferring to use internal APIs for the access.
This has nothing to do with whether indexing starts at 0 or 1.
Meanwhile, in present MATLAB, if you have
function out = test(x)
out = sum(x(1:10));
then you do not need to care whether x is a function handle or a variable. If indexing and invocation were different, you would need to:
if isnumeric(x) || islogical(x) || ischar(x)
out = sum(x[1:10]);
else
out = sum(x(1:10));
end
and have similar logic all over the place.
With the current setup in MATLAB, whatever is passed in just has to have a subsref method that can do lookups or invocation as needed, with implementation details hidden by the creator of the object. This is much more compatible with Object Oriented Programming than requiring that indexing and invocation be differentiated would be.
Rik
Rik on 3 Apr 2018
There are many people who complain about Matlab being 1-indexed, instead of 0-indexed. I would say both have their merit and 1-indexing is not so rare that it is extremely odd. If Matlab were designed today, I think it would be 0-indexed, but that is mostly just a hunch. The problem between the two being that this would be the cause of it being difficult to distinguish an array from a function is new to me though.
dpb
dpb on 3 Apr 2018
It would matter not what the initial indexing value would be from that standpoint; '0' could be just as likely a function argument as the array index is such contexts...blaming that on the choice of index puts the fault in wrong place (altho I don't see any way around it; it's no different than Fortran or C in that regards that I can see unless there's something else specifically you're complaining of).
Alan
Alan on 21 Mar 2018
Definitely this is in order of annoyance.
  1. I tend to use the Matlab command line quite a bit. In the Linux 64 bit R2017a, when I edit a command that I have used previously, at times the function hint tooltip remains on the command line. I believe that this is an "orphaned" or "zombie" display object, but the java gc must not recognize it as such because the only way to remove it is to restart Matlab. Frustrating! The screenshot below shows the offending function hint left over from some bygone nested command. The exception occurs when I try to right click on this orphaned hint window.
  1. Speaking of tooltips, I am using CentOS 7 with the GDM. Sometimes tooltips are blank and gray, sometimes they are legible. I have read some things claiming that the GDM doesn't have the correct fonts, just that sometimes it does! This is what happens when I click on the "More Help" link in the function hint window:
  1. Java memory management issues in Matlab using Simulink, signal logging and large variables. Plenty of memory left, but Java seems to be paging in and out the same 100 MB of memory.
Alan
Alan on 21 Mar 2018
Thanks for your response, Walter. The GDM that this CentOS is running happens to be 3.14.2, so that is definitely below 3.18, but the Matlab version is definitely R2017a, which should have this purported fix from R2016a, right?
Walter Roberson
Walter Roberson on 21 Mar 2018
Abhilash Sukumari
Abhilash Sukumari on 1 Mar 2018
I have 2 main frustrations with MATLAB:
  1. The resolution quality/plot qualities is really bad. I generally look forward to plotting the same in Pythons plot libraries such as matplotlib or seaborn to get a high quality plots.
  2. MATLAB does NOT remember break point positions if you have to restart the application. There is a round about way to achieve this but frankly speaking that is not the point and it frustrates me as a programmer to manually remember the positions where I have to place breakpoints.
Walter Roberson
Walter Roberson on 1 Mar 2018
With regards to breakpoints:
You could put a line or two of code into your finish.m to cause it to save the current breakpoints, and your startup.m could load the breakpoints.
Adam
Adam on 8 Feb 2018
Most frustrating thing for me at the moment is at times Matlab starts endlessly beeping at me with the error sound. At first I couldn't work out why beyond the obvious observation that I had left a line of code half-finished and therefore not syntactically correct. But that alone does not produce continuous beeping.
I realised though that this is in the case where the file I am editing and have left, temporarily, with an error in, is a class for which I currently have objects in the workspace.
I do like the fact that objects update themselves (where possible) to changes in the class definition. It is a big step forward from what used to happen, but constantly pinging an error sound at me while it, presumably, keeps checking for changes in the class, is really annoying. I don't always want to have to delete all my objects before editing a class and often I navigate away mid programming of a loop or if statement to work out what code I want to put in there. When I do I get this endless pinging until I comment out my half-finished code.
Yash Gondkar
Yash Gondkar on 25 Jan 2018
  1. In R2017b on Windows 10 the help browser 'shivers' while scrolling.
  2. I have Intel® HD Graphics 3000 driver 9.17.10.4459 and still had to force Matlab to use hardware opengl
  3. It always takes a lot of time for Matlab to close and also to open
Walter Roberson
Walter Roberson on 1 Mar 2018
The help browswer, jxbrowser, is not always the highest performance.
I see that about 2 years ago jxbrowser added hardware rendering https://jxbrowser.support.teamdev.com/support/discussions/topics/9000002806 but I suspect it is not yet used.
Abhilash Sukumari
Abhilash Sukumari on 1 Mar 2018
matlab is not graphic intensive application at all. I can run it very smoothly on my 10 year old laptop. Check what else is consuming your memory and also if any other application is draining out your processing power.
Omid Nabipour
Omid Nabipour on 18 Jan 2018
I am running MATLAB R2017b on a Linux system (CentOS 6.9) and I have encountered a very ugly and annoying problem! I have created a Simulink S-function (C++) which is used as a discrete model with fixed time steps. I am trying to build a controller by using the Simulink PID(z) block to input control commands into my S-function. Whenever I use the frequency response based tuning method, the model runs just fine, however when the tuning is over all of a sudden all of my blocks move around on their own, and all the signals overlap each other in a very ugly fashion. unfortunately I can't provide any screenshots, but when this happens it's as if the blocks start to stretch out and they move farther apart in random directions as I run the tuner again. this is extremely annoying and confusing and I couldn't find any similar issues on Google. ANNOYING!!!!!!!!
Also, for some reason my Simulink window keeps switching to fullscreen for no apparent reason. When it switches to fullscreen it becomes the active window, it stays on top of any other window open, for example if I select a folder window and Simulink is in fullscreen mode, I briefly see the folder on the screen and then Simulink pops on top. Also very ANNOYING!!! I believe these bugs are only in the Linux version.
Walter Roberson
Walter Roberson on 29 Jun 2017
As a guide: NVIDIA's CUDA devices generally perform 64 bit floating point at 1/32 or 1/24 of 32 bit floating point performance; however, some of the very high end cards handle it at 1/3 of single precision performance by having specialized hardware for it. We can expect that if it were just a small matter of software algorithms to get 64 bits at only a factor of 2 slower, that NVIDIA would have implemented that. We can therefore deduce that software floating point 64 bit emulation is about 1/24 the rate of single precision; that would tend to suggest that quadruple precision would tend to be about 1/24 of double precision for good software without hardware quadruple precision assist.
Jan
Jan on 29 Jun 2017
@Birk: This is the expected behavior: While modern pocessors are optimized to process doubles very efficiently, simulating the arithmetics in software must be remarkably slower. A factor of two is impossible.
Birk Andreas
Birk Andreas on 29 Jun 2017
Walter Roberson, thank you for the link! Regarding the symbolic computing toolbox: I know vpa. However, it is way too slow for some applications where fast numerical computations are required. In the meantime I tested the Advanpix toolbox. In my case the hit on computation time is still quite large (maybe faster than vpa but still too slow for me). I could live with a factor of two for qadruple precision but it is more like 100 or so. It is really a pity!
Walter Roberson
Walter Roberson on 28 Jun 2017
Birk Andreas, the Symbolic Computing toolbox supports arbitrary precision, up to 2^29 (over 500 million) decimal digits.
Providing extended precision for addition, subtraction, multiplication, and division is not so bad, but it is a fair bit of work to extend that to include all the trig functions, exp() and expm(), eigenvalues, and so on.
John D'Errico has a File Exchange contribution http://www.mathworks.com/matlabcentral/fileexchange/36534-hpf-a-big-decimal-class which does extended precision decimal for a number of operations.
Birk Andreas
Birk Andreas on 28 Jun 2017
There is no way to extend precison beyond double for fast numeric computations. There is a third party toolbox (not for free of course) which seems to do the right thing (I have not tested but it looks quite convincing: "Advanpix Multiprecision Computing Toolbox"). Why Mathworks can't you compete with the state of the art and build this into standard MATLAB already. Is it too difficult for you?
Dan
Dan on 2 May 2017
Functions and classes defined within a package should not have to import the package or refer to other members of the package with the package name ... the import should be automatic ...
Given the requirement to refer to the local package name within the class or function definitions ...
  • It is difficult to rename the package
  • It is difficult to place the package within another package
  • It clutters up the function and class code with import calls ...
Please fix...
Walter Roberson
Walter Roberson on 1 May 2017
Akua Agyeman:
I sometimes explain a fair bit in my contributions. Doing so takes a lot of writing. I could explain even more, but at what point do I stop explaining?
When I start writing, I often do not know that person asking the question knows anything about how to program a computer, or what an algorithm is, or about how computers store information. I do not know that they understand positioning notation for representing numbers; I do not know that they know how to add or subtract. If they have asked a question about, for example acceleration, then I do not know that they know what acceleration is, or about calculus, or about the concept of "rate of change" or "integration" or even what a curve is.
My explanation has to stop somewhere. I have to guess what the person understands and write to that level. If I underestimate them and they already know some concept then I have wasted a bunch of time explaining it, which wastes my time and their time. If I overestimate them and they do not know some concept, then I have not wasted any time, and the person can ask for clarification of the parts they do not understand.
To this you need to take into account that people often do not ask the question they think they are asking, or often omit information needed to understand what they really want to know. I could spend a lot of time explaining something, but it might turn out not to be relevant to what the person wanted to know, because the question was not clear. That wastes a lot of my time.
It is therefore more efficient to explain less and let the person clarify or ask questions. This might be a bit frustrating to the person to not have received a full response the first time, but there is a real cost to us providing responses to everything that the person might have meant, or to explain everything the person might not understand.
Akua Agyeman
Akua Agyeman on 1 May 2017
I get that people who use matlab are super-smart...but for us less exalted people, could people answer questions assuming less knowledge. Half the answers to the questions read like PhD thesis, not great when learning to program and use matlab...think PYTHON, Keep it simple.
Roozbeh Abtahi
Roozbeh Abtahi on 23 Mar 2017
I have worked with Matlab since windows 3.- and MS-Dos version and it has always been my favorite tool. However 2015 version is the worst thing which has ever happened to me. My company has changed from 2010 to 2015 and we have to work with this version for the next few years. Since 2005 we have developed more than hundred Matlab Tools which our engineers use them regularly. Now almost none of them works!
- The handle structure of Figures, GUI elements, Axes, etc. has been changed and we have to update tens of thousands of codes which many of them have been used as black box for years. Finding all of these bugs will take several months.
- Mat files are not compatible. You don't even receive an error message. Matlab just Crashs!!
- Matlab-Compile changes the appearance of GUI's
And we are just at the beginning. God knows how many more bugs are there!
Walter Roberson
Walter Roberson on 1 May 2017
By the way, you can double() an HG2 handle graphics handle to get to the old numeric version, and you can handle() that numeric version to get back to the object oriented handle. It is not promised that this will be supported indefinitely.
dpb
dpb on 23 Mar 2017
There are some changes that are truly fundamental, though, Steven. I've no idea, of course, of any specifics for the issues Roozbeh is running into, but one I've found here in the forum is really a killer for many enhanced plots is that the legend object is now mostly opaque so can't query it and the second (truly mind-boggling retrogression) has to do with bar that now there truly is no way to retrieve the bar midpoints for labeling bars, etc. At least before while difficult it could be done; now it is simply impossible. Why anybody would design such a thing is beyond ken.
Steven Lord
Steven Lord on 23 Mar 2017
1) Yes, the graphics system changed significantly in release R2014b. When making that large of a change, it's neither possible nor necessarily desirable to have everything work exactly as it did before. Making those changes enabled new functionality and bug fixes that users have been clamoring for, in some cases for years.
The main change that the new graphics system made is that graphics object handles are now truly handle objects instead of numbers. If you were trying to perform arithmetic on those handles (IMO dubious unless you were trying to get to "the next figure" from the current figure, and even then I probably just would have called figure) then you will need to modify that code. But many of the operations (including both set and get) should still work on the handle objects the same way they work on the numeric handles, as long as the properties you're accessing or modifying still exist.
2) If you are able to create a MAT-file that crashes MATLAB when you load it, please check the bug reports for the release you're using and/or contact Technical Support to determine if you have encountered a known bug (potentially with a workaround.) If it's not a known bug, Support can investigate and report it to the development staff, and the development staff may be able to provide a workaround.
3) I believe this is bug report 1293244, listed as being introduced in release R2015b and being fixed in the next release, release R2016a. There are three separate workarounds (two that can be applied before deploying and one that can be applied after deploying) listed in that bug report as well if upgrading is not an option.
Adam
Adam on 23 Mar 2017
Unfortunately there are occasions when a big change has to be made and the R2014b graphics changes were one of those. Backwards compatibility is usually very good with Matlab but sometimes after a long time fundamentals just have to change and there is no way backwards compatibility can be ensured. The documentation does give some help with the type of errors you will get and if I remember correctly Mathworks did produce an automated tool that could help with some fixes of UIs, but it certainly isn't a pleasant upgrade to have to do. On the plus side it was rare event and the graphics system from there forward should be largely compatible.
One version of Matlab (R2015a possibly) contained a bug in the Compiler that caused buttons to disappear (though the text still shows) when you compile a GUI. I don't remember off-hand if there was a workaround suggested for this. We upgrade with every Matlab so I just used the previous version for compiling, but that isn't a general solution.
Csaba
Csaba on 5 Mar 2017
One of my main problem is that there is no normal graphical ROI defined. I am working with spectra. There are several different ROIs can be useful on a spectrum (let say when substract a baseline from a spectrum). There is no easy way to define, modify, delete ROIs, not speaking about attaching ROIs to the spectrum.
Matlab supposed to be a vector (matrix) oriented tool, so it is annoying that such a simple feature is not implemented.
Csaba Bagyinka
dpb
dpb on 5 Apr 2017
I've never failed to get a robo-reply that the submittal was received. On service requests they've never failed to follow up. For an enhancement request, once they've acknowledged receipt, unless there were questions regarding what the request was actually for or wanted an example of how to use it, I don't really see what else you would expect?
For an enhancement request, I'd wager "Case Closed" simply means there wasn't seen to be any need for further clarification such as the above (which would imply to me you did a good job in crafting the submittal, "attaboy!" :) ) and that it is in that database in the sky awaiting its turn to hopefully be one of the chosen few.
There's a searchable database for bugs/fixes; I don't know if there is a list of the enhancement idea database or not--I can see TMW thinking that listing could be valuable to keep under wraps for competitive reasons.
Again, I'm not privy to any inside "dope", just my thinking based on longtime observation...
I've made enhancement requests that fix what seem to me to be obvious shortcomings or highly-needed improvements dating back nearly 20 yr that still haven't percolated to the top so don't feel slighted, you've done your part! :)
Csaba
Csaba on 5 Apr 2017
@Adam: No, there was no letter in the spam folder. @dpb: if there is way to send such a letter, there should be someone taking care. They should be at least polite.
dpb
dpb on 4 Apr 2017
I don't know there's much for them to say on an enhancement request...AFAIK almost everything gets into their internal database and that gets culled over by some internal process that eventually selects what features are added for each release. I don't think they ever reveal what's coming.
Adam
Adam on 4 Apr 2017
Have you checked your spam folders? I have had a few Mathworks support emails land in my spam folder because they tend to have lots of numbers in the e-mail title for the support ID that our spam filters tend catch and divert to junk.
Csaba
Csaba on 3 Apr 2017
So, I have contacted the Support. Later I got a letter that the case has been closed. There was no explanation why. Do you know what happens in this case? Why they did not even answer (let say, "you are stupid", or something)?
Csaba
Csaba on 9 Mar 2017
Thank you Steven, I did not know that. I will try to write this request.
Steven Lord
Steven Lord on 9 Mar 2017
This sounds like a reasonable enhancement request to send in to Technical Support. You can contact Support to file the enhancement request via the Contact Us link in the upper-right corner of this page. [Enhancement requests tend to carry more weight if they come directly from users, and if they include not just a description of what you want but also how you would use it and/or why you want it.]
Csaba
Csaba on 9 Mar 2017
Like what? I do not understand you comment. There is no such a toolbox (AFAIK). But anyway it should be basic not a toolbox (IMHO).
dpb
dpb on 8 Mar 2017
Mayhaps a Spectroscopy Toolbox is an enhancement?
Stefan Karlsson
Stefan Karlsson on 6 Jan 2017
I miss the ability to define your own workspace. When doing event driven programming in Matlab, there are 3 ways to share your own data to the callback functions:
  1. getappdata
  2. nested functions
  3. global variables
getappdata is fastest, except if you want to modify the data(it then requires copying, which the other methods do not). Its also ugly.
nested functions require your entire project to be done in a SINGLE m-file
global variables are a can of worms
Countrary to popular belief, there are currently situations where using the global workspace is simple the only logical way to go in Matlab. This is terribly annoying.
having the ability to define your own workspace for your project would solve this. Would also make it alot easier to read code(compared to huge m-files with nested functions, or ugly appgetdata).
defining your own workspace would be roughly equivalent to having nested functions that are allowed to reside in seperate m-files.
Hope I am wrong, so please enlighten me with your oppinions :)
Walter Roberson
Walter Roberson on 9 Mar 2017
"You could use comments of course, but code shouldn't need comments"
I don't think I would agree with that. Code can show what is being done, but for why it is doing it, you need comments.
As a simple example, when you uigetfile() and pull out a pathname, does the pathname end with a directory separator or not? The answer is operating system dependent, but most people do not know that. If your code after that needs the directory separator or needs it to be absent then you are going to have to have code to deal with it -- code that might look like redundant waste for people only accustomed to a single operating system. A tiny comment explains the situation, avoiding the risk that someone might come along and helpfully "clean up" the code and in so doing get it wrong.
When I am working with teams, using a source code control system, I make sure the SCCS automatically includes the change logs as comments. Those change logs can grow to be quite long; they also act as the institution memory about what has been done to the source file and why. Has the fix for bug #4327 been applied to this source file yet? Look in the comments from the change logs (and make sure that information is added to the change logs.)
No project of substance survives long without some kind of audit trail, and that is typically through comments.
Adam
Adam on 9 Mar 2017
There are no rules against using bad programming practices, I use plenty myself from time to time though I try to avoid them. But it is widely understood in pretty much every (sensible) language that globals are bad programming practice. I have never seen code that uses globals that doesn't have a better solution not using them.
In my current job I have sometimes worked in a team and sometimes, as now, I am the only person working with all our Matlab code, but in all cases I try to write my code as though other people will want to be able to read it and understand it. I don't always succeed, but it is an aim.
When I was working in a team I told my team-mates straight away that I wouldn't waste my time trying to understand what the inputs to a function are supposed to be and that I expect all public functions to use a
doc validateattributes
line for each input parameter except in cases where speed is vital. You could use comments of course, but code shouldn't need comments. I'm not saying I expect that everyone agrees with my standards, just that I'd rather just reprogram something myself than work out how someone's code works that just takes some input arguments and doesn't tell me what they are. If the code uses globals then I wouldn't even look twice at it because it clearly isn't reliable in a proper program that is broken down into non-local functions.
It depends where you work, but writing code under the iron-clad assumption that you will be the only person who will ever need to use it is risky to say the least!
Walter Roberson
Walter Roberson on 8 Mar 2017
The individual ownership model is simply unworkable in open source development
===
I have a friend who does QA for a networked product. They are the only person who has been with QA over three product generations: they know how the products does work, and how the product is intended to work, and they know how fungled-up customers are going to get if a particular aspect does not work properly. The developers have been with the product only one generation at most and don't know these things. But the developers have complete ownership of the code. So my friend can only file bug reports, not fix the product. And the developers don't believe that someone else might know more about the workings of the product, so they accuse my friend of having faked the test cases that show failures, which is pretty baffling considering that the test cases show exactly how to reproduce the problems.
Is that what you would call "well-organized" ? Silos? Where significant product defects are permitted to exist not because they are undetected or their exact cause is unknown, but because only one person "owns" the code and they decide they don't feel like fixing it?
Csaba
Csaba on 8 Mar 2017
@Walter Roberson: I trust you that at some places it is the case. But it is the question of organization of work and not coding. In a well organized places - in my opinion - there are well definied fractions of the code and they belong to separate and one person.
@dbp:
I think that your argument has nothing to do with "globals". "retaining all the nuances of such complexity in mind" can very much difficult without globals aswell. It is not an argument against globals. If you have a linear code, globals do not have more difficulty (IMHO). The same is true for the "coming back even a couple of months later, what more a year," argument. It might equally be difficult with or without globals.
Anyway, I think I am not forcing anybody to use globals but you are forcing me think that who is using globals is not an ordered man. Which is funny.
dpb
dpb on 8 Mar 2017
"But I do not agree with point 1 and point 3 [code size and lifetime]"
I'd think it patently obvious why both are there; I'd certainly put the code size target down at quite a lot lower than 100K LOC (unless a very high fraction of same is just "boilerplate" implementation or automatically generated such as template expansion for class definitions or the like) as retaining all the nuances of such complexity in mind is pretty-much out of the capability of "mere mortals" ability to cope with. Similar arguments hold for the time frame; unless one has truly tremendously-developed memory or the code itself is patently trivial, recalling precisely how it all relates when coming back even a couple of months later, what more a year, can be more than challenging. If it's a newcomer to the team taking over as in one of Walter's scenarios, then all bets are off...
While there are reasons to use a limited number of GLOBALs in very prescribed circumstances, should be avoided like the plague as a general rule.
Walter Roberson
Walter Roberson on 8 Mar 2017
"And also, I am not supposed to rewrite his/her code. It is his/her job."
Not anywhere I have worked: people sometimes were primary authors of code who would know the most about it, but when working together, we were always a team that had authority to modify code written by other people. People get ill; people go on vacation; people get promoted; people leave; people get assigned to other projects without enough time to make the modifications. The QA team had the authority to make fixes (QA did not always operate on the same shift as the original developers.)
Csaba
Csaba on 8 Mar 2017
@Jan Simon: I understand your point 2. And I agree with you in this. When I say "programming, it means one programmer. If many people make a big program it is a "cooperation of programmers" and not programming, or if you like "parallel programming" per analogiam parallel computing. If I have to use someone's code I do not expect anything 'global' from him/her. I expect input and output, so in this you are correct. Because it is not my code! And also, I am not supposed to rewrite his/her code. It is his/her job. If I have a i.e. interrupt where I can put code, it is not "my code", I am a guest there, this code belongs to other person, (s)he just let me write some lines into the subroutine (or maybe a full subrutine) and I would not mess up his code putting there my global variables, since I am a guest there.
But: I do not see any reason why not put global variables into my code where I have full controll. And I definitely would allow other programmers to put their - different - global variables into their own code. I have nothing to do with their global variables and they have nothing to do with my global variables. When I am calling a "guest" subroutine, not written by me - in this point I agree with you - there is no place for global variables.
But I do not agree with point 1 and point 3. I do not see the reason why you did put it here and therefore I cannot argue. If you are using globals only in linear part (excluding interrupts, etc. ) then .....?
I am not speaking about parallel computing. It is the same case as parallel programming.
Jan
Jan on 8 Mar 2017
@Csaba: I have worked on a code for clinical decision making with more than 300'000 lines of Matlab code (only code lines without counting the comments). Users can expand this program for research projects. Now imagine that the internal communication or the interface to the user supplied functions would use global variables. It would be a mess and impossible to control the reliability of the code.
As long as a code has some thousands of line and is maintained by one programmer only, global variables might look handy. But any good code tends to be re-used in larger projetcs. Then there are three limits which collides with using global variables (as a rule of thumb):
  1. 100'000 lines of code
  2. More than one programmer
  3. Development time exceeds 12 month
In all 3 cases a programmer cannot keep the overview over side-effects of modifications of a code line reliably. The only way to keep such projects in a stable state is reduce side-effects. Avoiding globals is the cheapest method to do this.
There is no way to debug a large program efficiently, when the communication happens using global variables: If the debugger stops in a certain function, there is no way to find out, which function is responsible for the last change of global variables. For small programs using the debugger for stepping through all lines might work. But if the code is hige and runs for several hours this is impossible. In opposite to this it is trivial to search in the dbstack, when the data is provided as inputs and outputs.
Here "globals" mean also storing data in the root object's UserData, using evalin('base') to use variables in the base workspace and files with non-unique names for interprocess communication.
Csaba
Csaba on 8 Mar 2017
@Adam and also @Guillaume
"If your important struct full of variables is global then literally anything can edit it at any point of your program or, worse still, delete it. Your function in which you use it has no control over any of this, it just has to hope that when it is called the global variable it expects is 'poofed' into its workspace in the state it wants it to be. When you are reading the code though you have no way of knowing what state this will be without intimately knowing all your code and how it all reacts with each other in every possible scenario."
It is usually not true. A function can reach global variables if I let it to do. If I do not let them to reach they cannot modify them. So interrupts, timers, etc. are ruled out of course (at least in my practice). I am - of course - using globals in the linear part of programing, i.e. an interrupt definitely cannot change a global variable, because I do not let it to do. I could not even imagine that somebody is defining global in such subroutines (sorry that I did not made it clear).
But in linear part ... why not.
And yes, it is my choice and I do not want to force anybody using them, but the definite rejection is not fair.
Steven Lord
Steven Lord on 8 Mar 2017
Csaba:
If the variables local to your function contain different values than you expect, basically only people who have access to modify your code could have changed their behavior.
If your variables that were passed into your function as input arguments contain different values than you expect, you have an obvious starting point to investigate the difference: the function (or call from the MATLAB prompt) that passed the variables into your function.
If the variables that your function retrieves from the global workspace contain different values than you expect, anyone who has access to the global workspace (including any code run at the MATLAB prompt or any function, class method, etc.) could have changed those values. I've had to debug code written by other people that failed because a global variable had changed value ... somewhere. It's not fun.
Guillaume
Guillaume on 8 Mar 2017
@Csaba, myabe this trivial example will make my point about lack of locality clearer:
function x = fun_noglobal ()
v = 1;
x = v;
end
function x = fun_global()
global v
v = 1;
x = v;
end
What is the value returned by each function? fun_noglobal is guaranteed to return 1. You have absolutely no way to know what fun_global will return without analyzing the whole program as an event or timer or interrupt may well have modified the value of the global in between the two lines.
Walter Roberson
Walter Roberson on 8 Mar 2017
Try taking over a non-trivial project written with less care; you can easily end up spending months remediating the use of global because something is stomping on your global variables and you can't tell where.
Adam
Adam on 8 Mar 2017
Structures full of variables being global is a recipe for bugs. The more important a variable is, the less reason there is for it to be global. Important variables are passed around with care. You should always know exactly what is operating on them and when.
If your important struct full of variables is global then literally anything can edit it at any point of your program or, worse still, delete it. Your function in which you use it has no control over any of this, it just has to hope that when it is called the global variable it expects is 'poofed' into its workspace in the state it wants it to be. When you are reading the code though you have no way of knowing what state this will be without intimately knowing all your code and how it all reacts with each other in every possible scenario.
You could program everything with global variables if you want in the same way that you can do object-oriented programming by making every function and property public so that everything can access everything. It's great, no need to worry about ownership of properties or worrying about code design because something that is private is not accessible where you feel you need it. It's great right up until you get a bug, then it ceases to be any fun at all when you realise the bug could have dropped in from anywhere since everything has access to everything.
It's the same with global variables. Nothing has ownership, nothing takes responsibility, nothing cares. Stuff is just either there when you want it or it isn't. If you simply pass the variable into a function as an argument then you have control over it.
Of course with structs this is still not great because structs are just a christmas tree you can hang anything on and you still have no idea what is actually on your struct when it lands in a function, without interrogating it in the code, which is why I rarely use them. Nevertheless, you still have better control than you do with just hauling in a global variable.
It's your choice. Some people like global variables. I have no idea why, but it's their life and their bugs to fix! I have my bugs to fix too, I just find they are usually more obvious to find.
Csaba
Csaba on 8 Mar 2017
@Guillaume: " One of the issue with global variables is the lack of locality." This is oxymoron. They are global because they have no locality. One would define as global because (s)he does not want it to be local. So calling for locality of something which should be global is funny.
Of course anything can be used without caution. But if you want to share variables between functions this can be very handy.
As we say there is no cure against stupidness.
I am usually defining full structures as global variables, in this case I should not always write that str=function any(str.....), I am just passing the necessary variables and assume that all functions needing the structure have it and they can modify and use.
Global variables are usually important variables and the name of them displays their importance. I would NEVER make 'i' (or even 'v' as in your example) global. It just has no meaning. So if you name the global variables carefully you would not make changes accidentally. But it is always true that you have to be careful. In a function you can make the same mistake with normal variables aswell (i.e. changing accidentally i within a for loop).
So I am not convinced, I like global variables and I had (yet) no problem with them because they are global.
Guillaume
Guillaume on 6 Mar 2017
@Csaba, One of the issue with global variables is the lack of locality. With this:
function foo()
v = somevalue;
%do something with v
%do some other stuff
%do something else with v
end
You are guaranteed that v will not change during the lifetime of foo unless foo changes it.
With:
function foo()
global v
%do something with v
%do some other stuff
%do something else with v
end
There is no guarantee that v will be the same value between the two times it is used. v might not even be in a valid state.
Debugging and tracking changes to global variables is more difficult since, by definition, any function could be changing the value of a global.
Walter Roberson
Walter Roberson on 6 Mar 2017
"getappdata is fastest"
getappdata requires locating the appdata associated with the given object and searching its structure for the named entity, and that needs to be done every time getappdata is executed. This is slower than using nested variables.
Csaba
Csaba on 5 Mar 2017
Why do you say "global variables are a can of worms"?? Other people say that "global variables are ugly".
Why do not you like global variables? Common workplace somehow is the same, is not it?
I personally like global variables. You should be careful using them but you should be careful with other things as well.
So what is the matter with global variables?
Stefan Karlsson
Stefan Karlsson on 7 Jan 2017
@Adam, last I tested matlab OOP was about 3 years ago. At that time, the performance impact was still far too large. I am considering handling large matrices, and with callbacks that are triggered very often(such as from timers).
However, if you have a small working example please share. Thanks!
@Walter, here is an example that shows my belief in how it works:
global uglyGlobal; %say that uglyGlobal is already a 1000x1000 mat
uglyGlobal(10:100,10:100) = 10;%fast, creates no copy here
prettyLocal = uglyGlobal;
uglyGlobal(10:100,10:100) = 0; %slow, prettyLocal needs to copy
uglyGlobal(10:100,10:100) = 10;%fast, creates no copy here
The point is that if you use only the global variable and not making any copies of it, you do not trigger any copy-on-write. am I mistaken? Of course this is an ugly way to work, hence my frustration
Walter Roberson
Walter Roberson on 6 Jan 2017
"getappdata is fastest, except if you want to modify the data (it then requires copying, which the other methods do not)"
Nearly all methods of modifying data require copying, because MATLAB is copy-on-write.
The one exception is for a variable that is unshared and which is both input to and output from a function and which is modified but no copies are taken in the function: in that case the variable might be modified in-place instead of being copied.
However, the above would not, I think, apply to the situation you describe, because you describe sharing variables between functions, so the variable would be shared.
Walter Roberson
Walter Roberson on 6 Jan 2017
Note: guidata is really getappdata()
Adam
Adam on 6 Jan 2017
A 4th option is to use handle-derived class objects to pass to callback functions. Changes to these are also seen in whatever other workspace has a (reference) copy of them.
Within a GUI you can also use guidata.
When I am working with event-based stuff though I always use a class-based OOP approach so have never used your options 1 or 3. I do now use nested functions more than I used to in certain specific places (still often within a class function), but the fact I can't add variables to their static workspace on command line when debugging annoys me as I do this a lot normally.
wenhao Yang
wenhao Yang on 16 Sep 2016
Of course, it's the red color.
Matt
Matt on 17 Aug 2016
Matlab is still one of the best tools for rapid engineering prototyping and simulation. However I have a few gripes as many do. First it is increasingly facing some stiff competition from free alternatives like python/numpy and Julia. Here is my list of issues.
1) It's still slow. Julia is 2-3 times faster and even numpy is faster once it's accelerated with cython, which is fairly easy to do. It would be nice if matlab had more accessible options to accelerate it's code.
2) The C interface is appalling. If you compare it to what you can do with python or Julia it's quite unfortunate. This ties into the acceleration problems item 1.
3) Modules, where are they? I hate the proliferation of .m files. Modern programming language allow you to organize your functions and methods into modules that can be imported en-masse. It also helps with the control of your namespace.
4) Object orientation is syntactically ugly and non intuitive. Python just destroys matlab here. The lack of modules and poor object orientation and/or limited functional programming paradigms hurt the use of matlab for more general purpose programming. It was obviously a late add on and obviously little research was done into how it is done well elsewhere (e.g. Python , Ruby etc.) Interestingly integration with java is a bonus for matlab. It could theoretically alleviate some of the object orientation or functional programming deficiencies, but can you use some of the more useful languages that sit on top of the java runtime? That might be interesting but I've never tried it.
5) Symbolic Toolbox: I think mupad was a step down from Maple. I can still do more with maple. I absolutely love the matlab integration of their symbolics. It makes maple syntax seem clunky. It's just annoying that it's less capable now and I think slower.
6) Linux support. Matlab 2016 will not work with the latest nvidia cards and the latest drivers on linux. There are opengl problems that no one wants to fix. I'd like to see this sort of thing improved.
Karan Gill
Karan Gill on 3 May 2017
Matt, could you provide more information on #5 Symbolic Math Toolbox? Further, if you could provide info on your theorem proving issues and performance issues, that'd be helpful.
Thanks, Karan.
Walter Roberson
Walter Roberson on 16 Sep 2016
Matt, you wrote "It was obviously a late add on and obviously little research was done into how it is done well elsewhere (e.g. Python , Ruby etc.)" . I demonstrated that those tools were primitive and very inefficient at the time that MATLAB implemented something functional (if not always the most efficient or flexible in that early release.) At the time of the MATLAB implementation, OOP was not being done well elsewhere, unless you want to count SmallTalk (which itself still had a lot of efficiency issues in that timeframe.)
Mathwork's second generation of object oriented programming (classdef based) could perhaps have been designed differently; that was R2008a.
Matt
Matt on 22 Aug 2016
I have a lot to say about performance and have even resorted to creating my own matrix toolbox for python that runs on a GPU. It shows how important a good foreign language interface can be, since it's fairly easy in a tool like Python/numpy to integrate outside code. In that case I was rewarded with code that ran some 10 to 100 times faster than matlab. I actually created a matlab interface to that library as well, but it was simply too difficult to interface as tightly with matlab vs what you are able to do with Python.
Right now I'm having a big problem with mupad performance. It's dog slow and uses virtually no parallelization. You do realize that theorem proving is embarrassingly parallel right? Most of the branches can be run independently of one another. I'm feeling sick right now watching 11 cores sitting idle whilst one core is pegged at 100% taking over an hour to do a calculation that I want to run maybe 1000 times.
I'm going to have to rewrite that in Julia or C++ or some other high performance language that supports multi-threading. As much as I love matlab, it's this sort of thing that draws me to other tools.
As for Matlab's module system, I can't say I've used it much. It still requires a .m file for each function though right? I would also be very leery of performance.
I'm not sure I understand Mr Roberson's comment with regards to Java. In my comment I praised the Java integration and was lamenting that I haven't used it more or seen more exploitation of that capability.
Adam
Adam on 22 Aug 2016
In general I like Matlab's OOP, though in fairness C++ is the only other language that I am familiar with so I don't really know how things work in languages like Python. Maybe ignorance is bliss or maybe I have just used it for long enough to get it to work as I want it to.
Certainly there are some gripes, but there are with any language's peculiarities. Having to define 'pass by reference' at a class level and then jump through hoops to make a hard copy of one of these classes on occasions is annoying, and the lack of the concept of 'constness' that is in C++ (and I assume various other languages) is something I miss. Matlab OOP also takes a little more care with respect to performance than some other languages since you can seriously slow down your code without realising if you just dive into OOP without understanding its nuances as I discovered in my earliest days using it.
I have started to use packages quite a lot, but they do lack something and I often wish I could import a package into a whole class rather than every function - as such I pretty much never import and just use the full qualification of a package class.
Guillaume
Guillaume on 18 Aug 2016
Packages are certainly something that I'd like MathWorks to improve on as at the moment they are more a hindrance than a help particularly when you need to refactor code.
Andreas Goser
Andreas Goser on 18 Aug 2016
Matt, I want to make sure you have had a chance to discuss your viewpoints with MathWorks engineers, in particular Techncial Support. Did you? I personally am keen on understanding the computational performance difference you mention. The majority of such differences brought to my attention could be turned around after examination by a MathWorks engineer.
Walter Roberson
Walter Roberson on 18 Aug 2016
"It was obviously a late add on and obviously little research was done into how it is done well elsewhere (e.g. Python , Ruby etc.)"
Well, if you consider December 1996 (MATLAB 5.0) "late". Java 1.0 was released in 1995. Both of those are before the release of Python 1.5, but after the release of Python 1.0, and a year after the first public release of Ruby 0.95, but pretty much simultaneous with the release of Ruby 1.0 . But, hey, the MATLAB developers should have been reading the research papers and been good oracles about what would turn out to work and be popular and what would not, right?
The reality of Java in those days was that it was too inefficient to be used for serious computation. javac did not even become available until November 2006.
John
John on 15 Aug 2016
The Matlab Crashes at least once a day for no reason since a year ago, data and script loss and so frustrating. Before there was no such problem.
Matlab becomes more and more microsoft office like, and more and more kids like. That's why craches all the time.
Very unhappy with the new versions. It's not professional anymore, it's just a piece of demonstration now.
Unfortunately I need to use it because of library built ages. Otherwise I really want to quit this piece of crappy.
Steven Lord
Steven Lord on 18 Aug 2016
Please send the crash log files to Technical Support. If the crashes are being caused by known issues, they may be able to offer a solution. If they are not caused by known issues, they can report them to the development staff for further investigation.
dpb
dpb on 16 Aug 2016
"...need to use it because of library built ages [I presume "ago" belongs in here?]"
If so, why not just stay with the last version that did what you needed and let the new stuff be debugged and brought to maturity instead of riding the bleeding edge?
I tend to agree on bloat, though...and quite a lot of the interface stuff
Walter Roberson
Walter Roberson on 23 Jun 2016
Stephen23
Stephen23 on 23 Jun 2016
@Tim Bigelow: What do you mean by the "variable page" This is not mentioned anywhere in the online documentation.
Do you mean the Variable Viewer, which as its name implies, is intended for viewing summaries of variables in the workspace?
Tim Bigelow
Tim Bigelow on 23 Jun 2016
the variable page is useless! How much does this software cost? Has nobody else figured out such simple stuff is non-functional?
Cant enter new numbers Can't enter more columns in the column number entry area
Can't copy and paste in cells
When numbers are entered manually, they are justified left or right?
why not all the same?
why do i have to enter two returns just to get one return in this suggestion page?
Tim Bigelow
Tim Bigelow on 23 Jun 2016
working with the variable page is extremely annoying! None of these really simple functions work at all well:
deleting a variable renaming a variable trying to delete one column in an array variable- I've yet to figure out how to make that happen duplicating a variable with a new name- and the help file for such basic things gives no clue?
Paul
Paul on 11 May 2016
It is not possible to view the contents of a 'containers.Map' type of variable in the Variable Editor. This makes code using this type difficult to debug.
Steven Lord
Steven Lord on 22 Sep 2022
You might be interested in the dictionary function introduced in release R2022b.