Main Content

Results for


Introduction
Comma-separated lists are really very simple. You use them all the time. Here is one:
a,b,c,d
That is a comma-separated list containing four variables, the variables a, b, c, and d. Every time you write a list separated by commas then you are writing a comma-separated list. Most commonly you would write a comma-separated list as inputs when calling a function:
fun(a,b,c,d)
or as arguments to the concatenation operator or cell construction operator:
[a,b,c,d]
{a,b,c,d}
or as function outputs:
[a,b,c,d] = fun();
It is very important to understand that in general a comma-separated list is NOT one variable (but it could be). However, sometimes it is useful to create a comma-separated list from one variable (or define one variable from a comma-separated list), and MATLAB has several ways of doing this from various container array types:
1) from a field of a structure array using dot-indexing:
struct_array.field % all elements
struct_array(idx).field % selected elements
2) from a cell array using curly-braces:
cell_array{:} % all elements
cell_array{idx} % selected elements
3) from a string array using curly-braces:
string_array{:} % all elements
string_array{idx} % selected elements
Note that in all cases, the comma-separated list consists of the content of the container array, not subsets (or "slices") of the container array itself (use parentheses to "slice" any array). In other words, they will be equivalent to writing this comma-separated list of the container array content:
content1, content2, content3, .. , contentN
and will return as many content arrays as the original container array has elements (or that you select using indexing, in the requested order). A comma-separated list of one element is just one array, but in general there can be any number of separate arrays in the comma-separated list (zero, one, two, three, four, or more). Here is an example showing that a comma-separated list generated from the content of a cell array is the same as a comma-separated list written explicitly:
>> C = {1,0,Inf};
>> C{:}
ans =
1
ans =
0
ans =
Inf
>> 1,0,Inf
ans =
1
ans =
0
ans =
Inf
How to Use Comma-Separated Lists
Function Inputs: Remember that every time you call a function with multiple input arguments you are using a comma-separated list:
fun(a,b,c,d)
and this is exactly why they are useful: because you can specify the arguments for a function or operator without knowing anything about the arguments (even how many there are). Using the example cell array from above:
>> vertcat(C{:})
ans =
1
0
Inf
which, as we should know by now, is exactly equivalent to writing the same comma-separated list directly into the function call:
>> vertcat(1,0,Inf)
ans =
1
0
Inf
How can we use this? Commonly these are used to generate vectors of values from a structure or cell array, e.g. to concatenate the filenames which are in the output structure of dir:
S = dir(..);
F = {S.name}
which is simply equivalent to
F = {S(1).name, S(2).name, S(3).name, .. , S(end).name}
Or, consider a function with multiple optional input arguments:
opt = {'HeaderLines',2, 'Delimiter',',', 'CollectOutputs',true);
fid = fopen(..);
C = textscan(fid,'%f%f',opt{:});
fclose(fid);
Note how we can pass the optional arguments as a comma-separated list. Remember how a comma-separated list is equivalent to writing var1,var2,var3,..., then the above example is really just this:
C = textscan(fid,'%f%f', 'HeaderLines',2, 'Delimiter',',', 'CollectOutputs',true)
with the added advantage that we can specify all of the optional arguments elsewhere and handle them as one cell array (e.g. as a function input, or at the top of the file). Or we could select which options we want simply by using indexing on that cell array. Note that varargin and varargout can also be useful here.
Function Outputs: In much the same way that the input arguments can be specified, so can an arbitrary number of output arguments. This is commonly used for functions which return a variable number of output arguments, specifically ind2sub and gradient and ndgrid. For example we can easily get all outputs of ndgrid, for any number of inputs (in this example three inputs and three outputs, determined by the number of elements in the cell array):
C = {1:3,4:7,8:9};
[C{:}] = ndgrid(C{:});
which is thus equivalent to:
[C{1},C{2},C{3}] = ndgrid(C{1},C{2},C{3});
Further Topics:
MATLAB documentation:
Click on these links to jump to relevant comments below:
Dynamic Indexing (indexing into arrays with arbitrary numbers of dimensions)
Nested Structures (why you get an error trying to index into a comma-separated list)
Summary
Just remember that in general a comma-separated list is not one variable (although they can be), and that they are exactly what they say: a list (of arrays) separated with commas. You use them all the time without even realizing it, every time you write this:
fun(a,b,c,d)

In the past 2 months, we had a lot of fun together playing in the two contests. To make future contests better and more appealing to you, we created a 1-minute survey to understand your experience.

Your feedback is critical to us. Thank you in advance and hope to see you in 2022!

After 7 weeks of fun, the MATLAB Central community 20th anniversary contests have concluded! Together, we shared the art of MATLAB and contributed to the battle against the global pandemic. See the fantastic stats below.

MATLAB Mini Hack Winners - Week 4

In Week 4, we invited the MATLAB Graphics team to help judge the entries. As the authors of the MATLAB functions used in every entry, they made sure every entry selected used a unique graphics function or technique from the other winners. Here are their choices:

1. Umbrellas by Shanshan Wang

Comment: Cool use of 'swarmchart' to make art from distributions; Only use of one of our newest graphics functions

2. Happy Sheep by Victoria

Comment: Cute!

3. Alien Giant by Jenny Bosten

Comment: Original idea, well textured, and efficient code

4. 3D Ultrasound by Adam Danz

Comment: Replicate source material very well. Effective use of lighting and material. Overall, impressive to produce this image given the limitation

5. Sunset in the Savanna by Sebastian Kraemer

Comment: Looks cool! Nice mix of 'image', 'fill' and 'scatter' commands.

6. Night Flight by Ratul Das

Comment: original; clever use of 'rectangle'

7. Lantern #2 by Tim

Comment: Nice use of 'getframe' to create a texture for 'surf' for a compelling picture

8. Geometric Design (6) by Daniel Pereira

Comment: Looks like some walls at MathWorks

9. Rosette 1313 by Alex P

Comment: Looks cool! Nice use of 'pcolor'

10. Mandelbrot contour by Sumihiro

Comment: Best use of contour!

11. Aim High by Murty PLN

Comment: Largest number of unique graphics objects for the Mini Hack (plot, patch,stairs,stem,text)

In the spirit of Mini Hack, the MATLAB Graphics team also created several cool graphs about the contest. Facing a similar space limit, I have picked only 2.

Bonus Prize Winners - Week 4

Congratulations to our 5 winners for their dual participation in the Treasure Hunt and the MATLAB Mini Hack. Yogiraj Bhagavatula, Pramod Devireddy, Devika U, FruitsLord, and Augusto Mazzei.

Lucky voters - Week 4

Congratulations to the lucky voters who cast the 12000th vote (Gordg Garin), 12500th vote (Eder Esteban Reyes), 13000th vote (Peram Balakrishna), 13500th vote (Emerson Nithiyaraj), 14000th vote(Sekar Naai), 14500th vote (Arika Amasarao), 15000th vote (Nikita Yakovlev), 15500th vote (Kesava Rao), and 16000th vote (Kundi Chandra Sekhar).

Grant Prize Winners

Finally, after validating entries and votes, we have picked the grand prize winners. We appreciate the time and effort you spent and the awesome entries you created. Huge congratulations!

1. Top 10 Authors of most voted entries

Each author will receive 5 customized T-shirts with the winning image and your name on the back of the T-shirts. You can choose the sizes and share them with your family or friends.

2. Top 10 Authors with most total votes

Top 10 contestants on the leaderboard will each get an Amazon gift card. The top 3 winners on the leaderboard will also earn special virtual badges.

  • Ciro Bermudez
  • KSSV
  • Juan Villacrés
  • Murty PLN
  • Pink_panther
  • Jenny Bosten
  • KARUPPASAMYPANDIYAN M
  • Jr
  • Adam Danz
  • Victoria

On behalf of the MATLAB Central community team, we thank you for joining our celebration of the MATLAB Central community’s 20th anniversary with us in the past 7 weeks. We hope you enjoyed these contests and look forward to seeing you in next year’s contests. Question: “What contests would you like to see next?”

In Week 3, we passed several amazing milestones! 1,000 Participants in the Treasure Hunt , 1,000 ENTRIES and 10,000 votes in the MATLAB Mini Hack , and $10,000 charity donation from both contests! I recommend you read Ned Gulley’s recent blog post , which is a fantastic summary of the contest highlights.

During the last week of this contest, we strongly encourage you to inspire your colleagues, classmates, or friends to participate by either VOTING or CREATING entries. To add some fun, we will give out a T-shirt to LUCKY voters who cast:

  • The 12000th vote
  • The 12500th vote
  • The 13000th vote
  • The 13500th vote
  • The 14000th vote
  • The 14500th vote
  • The 15000th vote
  • The 15500th vote
  • The 16000th vote

MATLAB Mini Hack Winners - Week 3

We’ve received many creative entries for our new categories. Congratulations to the winners! Each of you won a special edition T-shirt:

Greg, entry: better Christmas tree , category: Holidays

Ratul Das, entry: To All Pepperoni Lovers , category: Food

Peter Stampfli, entry: Louis V , category: Fractals

Adrien Leygue, entry: Stained Glass membrane , category: MathWorks Logo

Spencer Miesner, entry: ~Breathe~ , category: Album Cover

Stewart Thomas, entry: The only QR code you ever need , category: Black & White

Sebastian Kraemer, entry: sun , category: 3D

Jenny Bosten, entry: The joys of spring , category: Plant

Adam Danz, entry: MATropolis rooftop view , category: Illustration

Eric Ogier, entry: UFO , category: Fun

Simon Thor, entry: Mandelbrot in 52 characters , category: Concise

Tim, entry: Low Tide , category: Realism

Bonus Prize Winners - Week 3

We are giving out additional giveaways to participants of both the Treasure Hunt and the MATLAB Mini Hack . Congratulations to our 5 winners. Each of you has also won a special edition T-shirt.

  • Teodo
  • Dyuman Joshi
  • Shanshan Wang
  • Nirvik Sinha
  • Felipe Torres

Week 4

After the contest ends, we need additional time to validate entries for Grand Prize and Weekly Prize. The winners are expected to be announced within a couple of days after the contest ends. Thank you in advance for your patience.

In Week 2, the contest entered a new phase – the voting started! As of today, 6000+ votes have been cast on almost 1000 entries in the GALLERY! As a result, YOU raised $5000+ for Direct Relief in addition to the $2400 raised via the Treasure Hunt contest! We encourage you to continue sharing the contest to inspire others to participate by either voting or creating new entries so we can donate even more!

MATLAB Mini Hack Winners - Week 2

I won’t say judging is getting easier in Week 2 - amazing entries keep coming in every day. Congratulations to the winners! Each of you has won a special edition T-shirt.

Bonus Prize Winners - Week 2

We are giving out additional giveaways to participants of both the Treasure Hunt and the MATLAB Mini Hack . Congratulations to our 5 winners. Each of you has also won a special edition T-shirt.

  • Simon Thor
  • Eric Ogier
  • David Hill
  • Lyes Demri
  • Highphi

What’s new in Week 3?

In Week 3, we will add several new categories in which we hope to see more creative entries:

  • Holidays
  • Album covers
  • Food & Drinks
  • MathWorks logo
  • Fractals

In just one week, 500+ amazing entries were created. Math rocks and you rock!

Help us show the world the beauty of mathematics by sharing your work with your friends, classmates, or colleagues. You can also help fight the global pandemic by voting. For each vote, MathWorks will donate $1 to Direct Relief. See the Voting FAQs below for details.

MATLAB Mini Hack Winners - Week 1

Let’s start by saying: your awesome work made our judging VERY HARD! We came up with several categories with one winner each. Congratulations to the winners! Each of you won a special edition T-shirt:

Bonus Prize Winners - Week 1

As we announced last week, we are giving additional giveaways to participants of both the Treasure Hunt contest and the MATLAB Mini Hack contest . Congratulations to our 5 winners. Each of you also won a special edition T-shirt

  • Jan Orwat
  • warnerchang
  • Davide OLIVIERI
  • Daniel Niblett
  • KARUPPASAMYPANDIYAN M

Voting FAQs:

Q1: Who can vote?

Anyone with a MathWorks account can vote.

Q2: How many times can I vote?

There here is no limit to the number of votes you can cast. Vote for as many entries as you like (one vote per entry).

Q3: How do my votes increase MathWorks’ charity donation?

For every vote an entry gets, we will donate $1 to Direct Relief with a maximum amount of $20 donated per entry. MathWorks will donate up to a maximum of $20,000 based on the combined totals raised by task participation in the Treasure Hunt and voting in the MATLAB Mini Hack .

Q4. How do I win?

At the end of the contest, the top 10 participants on the leaderboard will each get an Amazon gift card and the top 3 will earn special badges. The 10 highest voted entries will win 5 customized T-shirts. See the full contest details.

Every week, we will also award surprise prizes for more fun.

Note that MathWorks staff are NOT eligible for prizes.

Q5: How do votes on my entries determine my rank on the leaderboard?

The total number of votes on ALL of your entries determines your rank on the leaderboard.

Q6: Do votes on remixed entries add votes to the original entry?

No. We count only direct votes on an entry.

Q7: Is the code (also) automatically compared to earlier submissions to determine the remix tree?

No. You have to remix an entry.

Just in 2 days since the contest started, we already have 200+ awesome entries in the MATLAB Mini Hack contests. We are excited to see so many talented and creative community members enjoying the contest and learning from each other.

If you haven’t created your entry, try remixing an entry you like. Make some SMALL changes and see what it would look like. Remix is highly encouraged in this contest.

If you haven’t entered the Treasure Hunt contest, give it a try. Your participation will not only win you a prize but also bump up MathWorks’ donation to a charity organization that fights the global pandemic.

Reminder:

  • Voting will start next Monday.
  • Weekly surprise giveaways will also be announced next Monday. Still time left to create your entries, original or remixed!

As part of MATLAB Central’s 20 year anniversary celebration, we created the MATLAB Mini Hack . The contest starts today on Oct. 4th!

What to do?

Generate an interesting image using up to 280 characters of MATLAB code.

Who can play?

Participants across all skill levels are welcome. Create original entries of your own code, remix others’ entries and make them your own, or simply vote on ENTRIES you love!

How to win prizes?

Those at the top of the leaderboard at the end of the contest will win up to $300 Amazon gift cards, 5 customized T-shirts, or special badges. Visit the prizes section on the contest page for more information.

To add more fun, we will award RANDOM PRIZES that every participant has a chance to win.

  • Each week, we will pick 5 players who participate in both the Treasure Hunt and MATLAB Mini Hack .
  • Each week, we will have different surprise giveaways.

Important Notes

  • The first week (Oct. 4th, 2021 ~ Oct. 10th 2021) is for creating entries only. Voting starts on Week 2.
  • Make sure you follow the contests (click the ‘follow the contests’ button on the top) to get notified when prizes are awarded and of other important announcements. We hope you are the winner!

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!

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.

Chen Lin
Chen Lin
Last activity on 23 Jan 2021

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.

Similar to what has happened with the wishlist threads (#1 #2 #3 #4 #5), the "what frustrates you about MATLAB" thread has become very large. This makes navigation difficult and increases page load times.
So here is the follow-up page.
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)
Jan
Jan
Last activity on 4 Oct 2024

After reading Rik's comment I looked for a list of Matlab releases and their corresponding features. Wiki: Matlab contains an exhaustive list, but what about having a lean version directly in the forum?
If this is useful, feel free to expand the list and to insert additions. Thank you.
Rik
Rik
Last activity on 4 Nov 2022

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).
Dear MATLAB community,
How can I help my close friend who's bad at math and programming learn MATLAB?
He's a final year chemical engineering student who struggles even to plot two functions on the same graph in his computational fluid dynamics class (there was no prereq for matlab skills).
In his first year, I saw him get dragged through the introductory engineering classes which was his first encounter with MATLAB. Students were taught a few rudimentary programming skills and then were expected to make a code for a 'simple' tic-tac-toe game. It took him hours of blank looks and tutoring to even understand the simplest of boolean operators. He was never able to write a working function without the supervision of a friend or tutor. Needless to say, he was permanently scarred by the experience and swore to avoid using it forever.
After 3 years of avoiding MATLAB, he realised how not knowing it hurt him during his final year project. He had to solve a system of pdes to model the performance of a reactor and practically speaking, MATLAB was the most suitable software at hand. He ended up having to get a friend to help him code the equations in while also having to oversimplify his model.
The weird thing is that: most students from his chemical engineering faculty were not expected or encouraged to use MATLAB, almost all of their prior assignments required no use of MATLAB except that infamous first year course, and most of his peers also avoided using MATLAB and resorted to Excel. It is my understanding that Excel cannot match MATLAB's efficiency and clarity when solving calculus problems so it was not uncommon to see extremely long Excel spreadsheets.
Anyway, my friend is, with the help of a friend's past year MATLAB codes, trying to finish up his computational fluid dynamics assignment that's due soon. He finishes university in 2 weeks time.
Even though he knows that not every engineer has to use MATLAB in the workplace, he somehow wishes he was able to learn MATLAB at his glacial pace. I find it such a pity that he was never able to keep up with the pace of learning that was expected which begs the question: are students who are too slow at learning programming better of in a different field of study?
If you've managed to read to the end of this, thank you so much. I just don't know how to help my friend and I'm hoping some of you might be able to suggest how I can help him be better at it. I believe he has potential but needs special help when it comes to MATLAB.
All helpful and constructive suggestions considered,
Thank You All

Hi there! This is kind of an unusual question, but here it goes. I am a big time Matlab enthusiast and I met some of your representatives at Formula Student Germany back in August. There was a booth were your product was showcased but most importantly there was Matlab merchandise such as stickers, rub-on-tattoos and pens with the mathworks logo being handed out. This merchandise is increadibly popular with me and my nerdy friends. But sadly I didnt bring much with me from the event. Is it possible to get ahold some of it? Is it for sale? Are you willing to sponsor some geeky engineering students?

I am new in MATLAB programming. I want to learn matlab . I want to know about is any matlab or simulink contest available. Please answer me. Thanks