主要内容

Results for


Join our celebration of the 20th anniversary of MATLAB Central community! You are invited to enter 2 contests - A Treasure Hunt and a MATLAB Mini Hack - to have fun and win prizes.

How to Play

  • In the Treasure Hunt, complete 10 fun tasks to explore the ‘treasures’ in the community.
  • In the MATLAB Mini Hack, use up to 280 characters of MATLAB code to generate an interesting image. Simply vote for the entries that you like or share your own entries to gain votes.

Prizes

You will have opportunities to win compelling prizes, including special edition T-shirts, customized T-shirts, Amazon gift cards, and virtual badges. Your participation will also bump up our charity donations.

Ready to participate?

Visit the community contests space and choose the contest you’d like to enter. Note that:

  • You need a MathWorks account to participate. If you don’t have a MathWorks account, you can create one at MathWorks sign in .
  • Make sure you follow the contests (click the ‘follow the contests’ button on the top) to get notified for prize information and important announcements.

For the full contest rules, prizes, and terms, see details here .

We hope you enjoy the contests and win big prizes. NOW, LET THE CELEBRATION BEGIN!

Let's say MathWorks decides to create a MATLAB X release, which takes a big one-time breaking change that abandons back-compatibility and creates a more modern MATLAB language, ditching the unfortunate stuff that's around for historical reasons. What would you like to see in it?
I'm thinking stuff like syntax and semantics tweaks, changes to function behavior and interfaces in the standard library and Toolboxes, and so on.
(The "X" is for major version 10, like in "OS X". Matlab is still on version 9.x even though we use "R20xxa" release names now.)
What should you post where?
Wishlist threads (#1 #2 #3 #4 #5): bugs and feature requests for Matlab Answers
Frustation threads (#1 #2): frustrations about usage and capabilities of Matlab itself
Missing feature threads (#1 #2): features that you whish Matlab would have had
Next Gen threads (#1): features that would break compatibility with previous versions, but would be nice to have
@anyone posting a new thread when the last one gets too large (about 50 answers seems a reasonable limit per thread), please update this list in all last threads. (if you don't have editing privileges, just post a comment asking someone to do the edit)
Is anyone else disappointed with uifigures? It seems apparent that these will eventually replace traditional figures, but there is still so much that doesn't quite work. I've tinkered with uifigures since their introduction in release 2016a, but even in 2020a I can't reliably export a uifigure to a graphics file. Sure it works sometimes, but not if a uipanel is present. The exportgraphics command is not as powerful as the print command, leaving some graphic formats (such as *.svg and *.eps) unsupported. How do you generate graphic files of a specific size? You can't even use subplots without overriding the default AutoResizeChildren setting!
Everything with uifigures seems to be slower and less stable than the figure variant. App Designer is much better than GUIDE, but that is not exactly high praise. I would rather generate "apps" programatically across several files instead of dealing with a single-file class definition containing 1000+ lines.
Where is this transition going? MATLAB graphics are moving away from Java in favor of JavaScript, and I'm not sure that we are at all ready for that.

Happy New Year, everyone! We hope you enjoyed the Cody contest in 2020, learned new MATLAB skills, and made a friend or two. While the 2020 contest has concluded, the fun and learning never end.

Please take the 1-minute survey to talk about your experience (only 2 required questions). Our goal is to make future contests better and more appealing to you, so your feedback is critical to us.

Thank you in advance and hope to see you again in the 2021 contest.

We are excited to announce that Cody Contest 2020 starts today! Again, the rule is simple - solve any problem and rate its difficulty. If you have any question, please visit our FAQs page first. Want to know your ranking? Check out the contest leaderboard .

Happy problem-solving! We hope you are a winner.

Below are some FAQs for the Cody contest 2020. If you have any additional questions, ask your questions by replying to this post. We will keep updating the FAQs.

Q1: If I rate a problem I solved before the contest, will I still get a raffle ticket?

A: Yes. You can rate any problem you have solved, whether it was before or during the contest period.

Q2: When will I receive the contest badges that I've earned?

A: All badges will be awarded after the contest ends.

Q3: How do I know if I’m the raffle winner?

A: If you are a winner, we will contact you to get your name and mailing address. You can find the list of winners on the Cody contest page .

Q4: When will I receive my T-shirt or hat?

A: You will typically receive your prize within a few weeks. It might take longer for international shipping.

Q5: I'm new to Cody. If I have some questions about using Cody, how can I get help?

A: You can ask your question by replying this post. Other community users might help you and we will also monitor the threads. You might also find answers here .

Q6: What do I do if I have a question about a specific problem?

A: If the problem description is unclear, the test suite is broken, or similar concerns arise, post your question(s) as a comment on the specific problem page. If you are having a hard time solving a problem, you can post a comment to your solution attempt (after submitting it). However, do not ask other people to solve problems for you.

Q7: If I find a bug or notice someone is cheating/spamming during the contest, how can I report it?

A: Use Web Site Feedback . Select "MATLAB Central" from the category list.

Q8: Why can't I rate a problem?

A: To rate a problem, you must solve that problem first and have at least 50 total points.

Meta threads have a tendency to grow large. This has happened several times before (the wishlist threads #1 #2 #3 #4 #5, and 'What frustrates you about MATLAB?' #1 and #2).
No wonder that a thread from early 2011 has also kept growing. After just under a decade there are (at time of writing) 119 answers, making the page slow to load and navigate (especially on mobile). So after a friendly nudge; here is a new thread for the things that are missing from Matlab.
Same question: are there things you think should be possible in Matlab, but aren't? What things are possible with software packages similar to Matlab that Matlab would benefit from? (note that you can also submit an enhancement request through support, although I suspect they will be monitoring activity on this thread as well)
What should you post where?
Wishlist threads (#1 #2 #3 #4 #5): bugs and feature requests for Matlab Answers
Frustation threads (#1 #2): frustations about usage and capabilities of Matlab itself
Missing feature threads (#1 #2): features that you whish Matlab would have had
Next Gen threads (#1): features that would break compatibility with previous versions, but would be nice to have
@anyone posting a new thread when the last one gets too large (about 50 answers seems a reasonable limit per thread), please update this list in all last threads. (if you don't have editing privileges, just post a comment asking someone to do the edit)
Rik
Rik
Last activity 2022-11-4

There are multiple ways to create a graphical user interface (GUI) in Matlab. Which method is the best depends on multiple factors: the complexity of the project, to what extent it should be a long-term solution, on what releases your GUI should work, your available time, your skill level, and probably other factors I'm forgetting.
To keep the thread clear I'll attempt to provide a short outline a few ways in this question, and leave the details for the answers. (@anyone with editing privileges: feel free to update the section below if I missed something important and am slow in editing this question)
---------------------------------------------------------------------------------------------------
GUIDE
GUIDE is probably the first tool new users will encounter. It is very useful for quickly putting something together, but it is otherwise fairly limited. It requires maintaining (and distributing) both a .m and a .fig file. Note that the GUIDE environment will be removed in a future release. After GUIDE is removed, existing GUIDE apps will continue to run in Matlab but they will not be editable in GUIDE. If you're starting a new GUI, don't use GUIDE. If you're updating an existing GUIDE GUI, migrate it to AppDesigner. In R2021a the first step for this removal was taken: all templates except the blank template have been removed.
GUILT
Although I haven't had a detailed look myself, it seems a list like this is not complete without at least mentioning the GUI Layout Toolbox, which is available on the file exchange and offers a lot of customization options.
Programmatic GUIs
You can bypass GUIDE and use the normal figures and functions like uicontrol to build GUIs from code. This makes the design less visual, but more flexible for future additions.
App Designer
The official successor to GUIDE, AppDesigner is not based on functions, but works similar to a class. It uses uifigure and mostly uses graphical elements that are incompatible with 'normal' GUIs that are created with a figure (or .fig).
This is the 5th installment of the wish-list and bug report thread.
This topic is the follow on to the first Wish-list for MATLAB Answer sections and second MATLAB Answers Wish-list #2 (and bug reports). The third started out as New design of the forum - grey on white and the fourth MATLAB Answers Wish-list #4 (and bug reports) is also growing so large it is slow to load and navigate.
Same idea as the previous ones: one wish (or bug report) per answer, so that people can vote their wishes.
What should you post where?
Wishlist threads (#1 #2 #3 #4 #5 #6): bugs and feature requests for Matlab Answers
Frustation threads (#1 #2): frustations about usage and capabilities of Matlab itself
Missing feature threads (#1 #2): features that you whish Matlab would have had
Next Gen threads (#1): features that would break compatibility with previous versions, but would be nice to have
@anyone posting a new thread when the last one gets too large (about 50 answers seems a reasonable limit per thread), please update this list in all last threads. (if you don't have editing privileges, just post a comment asking someone to do the edit)
Summary:
Dynamically accessing variable names can negatively impact the readability of your code and can cause it to run slower by preventing MATLAB from optimizing it as well as it could if you used alternate techniques. The most common alternative is to use simple and efficient indexing.
Explanation:
Sometimes beginners (and some self-taught professors) think it would be a good idea to dynamically create or access variable names, the variables are often named something like these:
  • matrix1, matrix2, matrix3, matrix4, ...
  • test_20kmh, test_50kmh, test_80kmh, ...
  • nameA, nameB, nameC, nameD,...
Good reasons why dynamic variable names should be avoided:
There are much better alternatives to accessing dynamic variable names:
Note that avoiding eval (and assignin, etc.) is not some esoteric MATLAB restriction, it also applies to many other programming languages as well:
MATLAB Documentation:
If you are not interested in reading the answers below then at least read MATLAB's own documentation on this topic Alternatives to the eval Function, which states "A frequent use of the eval function is to create sets of variables such as A1, A2, ..., An, but this approach does not use the array processing power of MATLAB and is not recommended. The preferred method is to store related data in a single array." Data in a single array can be accessed very efficiently using indexing.
Note that all of these problems and disadvantages also apply to functions load (without an output variable), assignin, evalin, and evalc, and the MATLAB documentation explicitly recommends to "Avoid functions such as eval, evalc, evalin, and feval(fname)".
The official MATLAB blogs explain why eval should be avoided, the better alternatives to eval, and clearly recommend against magically creating variables. Using eval comes out at position number one on this list of Top 10 MATLAB Code Practices That Make Me Cry. Experienced MATLAB users recommend avoiding using eval for trivial code, and have written extensively on this topic.
Inspired by Chad Greene's " MATLAB jokes or puns " thread, and in celebration of 15 years of the MathWorks Community site, does anyone out there want to share their poetic creativity? Limericks, haiku, sonnets... Go!
And to start off, my (slightly off-topic) submission on Chad's thread:
There was an old math guy called Cleve
who, while teaching, a pipe-dream conceived:
of a language so clean
you can say what you mean!
From our suffering we've all been relieved.
Edit: due to the increasing size of this thread, it is continued here.
What should you post where?
Wishlist threads (#1 #2 #3 #4 #5 #6): bugs and feature requests for Matlab Answers
Frustation threads (#1 #2): frustations about usage and capabilities of Matlab itself
Missing feature threads (#1 #2): features that you whish Matlab would have had
Next Gen threads (#1): features that would break compatibility with previous versions, but would be nice to have
@anyone posting a new thread when the last one gets too large (about 50 answers seems a reasonable limit per thread), please update this list in all last threads. (if you don't have editing privileges, just post a comment asking someone to do the edit)
This topic is for features you would like to see for the MATLAB Answers facility itself, and also for bug reports about the MATLAB Answers facility.
This topic is the follow on to the first Wish-list for MATLAB Answer sections and second MATLAB Answers Wish-list #2 (and bug reports). Those grew large enough to become unwieldy; and Mathworks has made enough changes to make a number of the past points no longer of relevance. More recently there was the limited purpose New design of the forum - grey on white which turned into a bug and wish list; I have renamed that for continuity.
I suggest one wish (or bug report) per answer, so that people can vote their wishes.
The community is very helpful, yet I feel really powerless that I cannot find the appropriate way to code, nor find the problems with the codes I have written. I have read numerous books on MATLAB, mostly related with science and engineering applications. Any advice to improve would be greatly appreciated. Thanks.
Chad Greene
Chad Greene
Last activity 2023-9-12

Are there any good Matlab jokes? I don't mean why or any other Easter eggs, I mean good jokes involving Matlab. Actually, that bar may be a bit too high. Any jokes, good or bad, let's hear 'em.
NOTE: this discussion is continued at MATLAB Answers Wish-list #6 (and bug reports)
I've opened MATLAB Answers this morning and found the new design.
The field for typing the "Body" does not consider the font settings of my browser anymore, such that my preference of sans-serif fonts is ignored. In addition the text color is a medium gray, which is hard to read for me due to the too light contrast.
Blank lines in the code let two separate code boxes appear. This makes almost all code, I've posted in the forum, invalid. It has been discussed repeatedly, that blank lines in the code confuse the indentation of the display in the forum and that this is a really bad idea. But instead of improving this, it is made severely worse now.
The new design contains even more white space, such that standard questions cannot be answered without extensive vertical scrolling. It is a very bad drawback, that I cannot see the question while I type the answer.
There is still no suggestion to use a proper code formatting, such that I have to spend 20% of my forum time typing corresponding comments as before.
But I'm coming back to the most important problem for me: It is a physical problem for me to read the low contrast grey on white text. Does anybody know a tweak or CSS trick to increase the readability?
TMW, please take into account that this new design is physically hard to read for people without young and 100% perfect eyes. This is very annoying for me.
Splitting code blocks at white lines is simply a bug. I cannot imagine why this error has not been detected before the new design has been published. The argument, that TMW is extremely conservative with changes in the forum to ensure a stability does not convince me anymore.
[EDITED] The box around the thread, the preview box, the boxes for preformatted text and code have a grey background now. So some text is even medium grey on light grey.
I'd be glad if the designers refocus on the purpose of the forum. Whatever this purpose might be, the optical reception of the characters is fundamental.
What MATLAB tools or functions have you been thinking about making but haven't quite gotten around to it?
It can be something specific to your work if you'd like, but it's preferably:
  • the kind of tool or task that we don't really expect in the next MATLAB release (ie., not a frequent entry in a MATLAB wishlist)
  • something that would be useful to you and (hopefully) others if it existed.
  • something that could conceivably be made by people(s) in the user community
Think of it maybe as a file exchange wishlist.
Votes for good ideas . I guess you'll get more votes if it's an idea others want to see made as well.
Probably no single accepted answer, but it would be nice to see what people have thought about and maybe we can bring a few ideas to fruition (or find that someone's already done it)
For example:
  • I've been wanting to write an object-oriented replacement for the NURBS toolbox which is a great toolbox but is very unwieldy to use.
I would like to receive your feedback:
  • would you find useful to have spellcheck built into the MATLAB Editor?
(Consider also an associated toggle, positioned somewhere in the Editor, that would enable/disable the spellcheck for selective use)
Lately, I am writing many quick analyses for publish() and I find that first publishing to MS Word (to check the spelling) and then re-publishing to .html, after manual corrections, disrupts the working.
IMHO, the idea to include spellcheck into the editor would be consistent with the renewed visibility of the PUBLISH tab.
NOTE: this discussion is continued at MATLAB Answers Wish-list #6 (and bug reports)
This topic is for features you would like to see for the MATLAB Answers facility itself, and also for bug reports about the MATLAB Answers facility.
This topic is the follow on to the earlier Wish-list for MATLAB Answer sections. That topic grew large enough to become unwieldy; and Mathworks has made enough changes to make a number of the past points no longer of relevance. There was also a more limited purpose <http://uk.mathworks.com/matlabcentral/answers/216662-new-design-of-the-forum-grey-on-white-wish-list-3-bug-reports
I suggest one wish (or bug report) per answer, so that people can vote their wishes.
Hello all,
Please explain good MATLAB programming practice methods. It will help to the guys who are new to programming like me.
Previously I used
for i=1:10
after following some suggestions from this answers pages I learnt to use
for i1=1:100
This is the good way to write programs.
Like this, as a professional programmer, please mention some good programming practice techniques.
It will useful to all!