Contenido principal
Results for
What amazing images can be created with no more than 280 characters of MATLAB code? Check out the GALLERY from the MATLAB Mini Hack 2022 contest.
Vote on your favorite MATLAB images before Oct. 30th! We will give out MathWorks T-shirt to 10 lucky voters.
How can I vote?
You can vote for an entry by clicking on the heart icon on an entry card or the vote button on the entry detail page.
We had another wonderful week of community contests 2022. In week 2, the voting for Mini Hack started! About 1000 votes have been cast on 300+ entries. In Cody 10th Anniversary contest, we already have 85 finishers for the two special groups: Matrices and Arrays and Plotting and Visualization.
Now, it’s time to announce the weekly winners!
MATLAB Mini Hack Winners - Week 2
Amazing entries keep coming in every day. In week 2, we announced a space category to celebrate the milestone of NASA’s Dart mission. We’ve picked 4 winners for this new category.
- Stewart Thomas, Lunar Shadows, category: space
- Teodo, NASA's DART Dimorphos Impact, category: space
- Simon Thor, Starry night, category: space
- Abdullah Caliskan, spacetime, category: space
Winners of other categories are:
- MvLevi, Personlized Lyapunov Fractal, category: File Exchange
- KARUPPASAMYPANDIYAN M, Moon View at MATropolis!, category: File Exchange
- Jan Studnicka, Butterfly, category: animal
- Brandon Caasenbrood, Periodic Minimal Surface, category: 3d
- Basil Imoberdorf, Zoom of Fractal action #3, category: fractals
- Pink_panther, Seaweed on Pandora, category: nature
Congratulations! Each of you won a MathWorks T-shirt. If this is the second time you won, you have the option to choose a MathWorks hat or a coffee mug!
Cody 10th Anniversary Winners - Week 2
- The top 3 players for solving most problems in week 2 are Mohammed, Armando Longobardi, and Stefan Abendroth, Congratulations! Each of you won an Amazon gift card.
- You don’t need to be an expert or spend tons of time to win! As long as you participate, you have the opportunity to win MathWorks T-shirts. Week 2 lucky winners are Dylan Baker and Takumi.
What’s new in week 3?
MATLAB Mini Hack 2022:
- Week 3’s new category is nature! We look forward to seeing more nature-themed creative entries from you!
- You are able to leverage up to 2 File Exchange submissions in your code.
Cody 10th Anniversary:
- Week 3 special problem group is Programming Constructs. Have fun!
New in R2022b: GridSizeChangedFcn
tiledlayout() creates a TiledChartLayout object that defines a gridded layout of axes within a figure. When using the 'flow' option, the grid size becomes dynamic and updates as axes are added or as the figure size changes. These features were introduced in R2019b and if you're still stuck on using subplot, you're missing out on several other great features of tiledlayout.
Starting in MATLAB R2022b you can define a callback function that responds to changes to the grid size in flow arrangements by setting the new gridSizeChangedFcn.
Use case
I often use a global legend to represent data across all axes within a figure. When the figure is tall and narrow, I want the legend to be horizontally oriented at the bottom of the figure but when the figure is short and wide, I prefer a vertically oriented legend on the right of the figure. By using the gridSizeChangedFcn, now I can update the legend location and orientation when the grid size changes.
Demo
gridSizeChangeFcn works like all other graphics callback functions. In this demo, I've named the gridSizeChangedFcn "updateLegendLayout", assigned by an anonymous function. The first input is the TiledChartLayout object and the second input is the event object that indicates the old and new grid sizes. The legend handle is also passed into the function. Since all of the tiles contain the same groups of data, the legend is based on data in the last tile.
As long as the legend is valid, the gridSizeChangedFcn updates the location and orientation of the legend so that when the grid is tall, the legend will be horizontal at the bottom of the figure and when the grid is wide, the legend will be vertical at the right of the figure.
Since the new grid size is available as a property in the TiledChartLayout object, I chose not to use the event argument. This way I can directly call the callback function at the end to update the legend without having to create an event.
Run this example from an m-file. Then change the width or height of the figure to demonstrate the legend adjustments.
% Prepare data
data1 = sort(randn(6))*10;
data2 = sort(randn(6))*10;
labels = ["A","B","C","D","E","F"];
groupLabels = categorical(["Control", "Test"]);
% Generate figure
fig = figure;
tcl = tiledlayout(fig, "flow", TileSpacing="compact", Padding="compact");
nTiles = height(data1);
h = gobjects(1,nTiles);
for i = 1:nTiles
ax = nexttile(tcl);
groupedData = [data1(i,:); data2(i,:)];
h = bar(ax,groupLabels, groupedData, "grouped");
title(ax,"condition " + i)
end
title(tcl,"GridSizeChangedFcn Demo")
ylabel(tcl,"Score")
legh = legend(h, labels);
title(legh,"Factors")
% Define and call the GridSizeChangeFcn
tcl.GridSizeChangedFcn = @(tclObj,event)updateLegendLayout(tclObj,event,legh);
updateLegendLayout(tcl,[],legh);
% Manually resize the vertical and horizontal dimensions of the figure
function updateLegendLayout(tclObj,~,legh)
% Evoked when the TiledChartLayout grid size changes in flow arrangements.
% tclObj - TiledChartLayout object
% event - (unused in this demo) contains old and new grid size
% legh - legend handle
if isgraphics(legh,'legend')
if tclObj.GridSize(1) > tclObj.GridSize(2)
legh.Layout.Tile = "south";
legh.Orientation = "horizontal";
else
legh.Layout.Tile = "east";
legh.Orientation = "vertical";
end
end
end
Give it a shot in MATLAB R2022b
- Replace the legend with a colorbar to update the location and orientation of the colorbar.
- Define a GridSizeChangedFcn within the loop so that it is called every time a tile is added.
- Create a figure with many tiles (~20) and dynamically set a color to each row of axes.
- Assign xlabels only to the bottom row of tiles and ylabels to only the left column of tiles.
Learn about other new features
This article is attached as a live script.
You might have read the news that NASA successfully crashed a spacecraft into an asteroid to alter the asteroid’s course. But did you know the spacecraft’s autonomous guidance system was developed in MATLAB and C++? Check out our latest blog post to learn more details.
Let’s celebrate this scientific milestone by creating astronomy-themed entries in the Mini Hack contest. Be creative and leverage the existing submissions in File Exchange. We will award special prizes to the best entries.
Simulink is a block diagram environment used to design systems with multidomain models, simulate before moving to hardware, and deploy without writing code. In this livestream, Sam and Nishan will build up the basics of getting started using Simulink to build models.
Sign up here to get notification when it start streaming at 11:00 am (EDT) on Oct 13 view your timezone
Just in one week, 200 amazing images were created in the Mini Hack contest and 20,000 solutions were submitted in the Cody contest. What an amazing week! Time to announce the winners.
MATLAB Mini Hack Winners - Week 1
Your awesome work made our judging VERY HARD! We came up with several categories for winning entries. Congratulations to the winners! Each of you won a MathWorks T-shirt:
- Pink_panther, entry: Let's Go Fruity: Strawberry, category: File Exchange
- Lateef Adewale Kareem, entry: Umbrella, category: File Exchange (nice use of your own File Exchange entry)
- Teodo, entry: Shock wave, category: creative
- Basil Imoberdorf, entry: Colorful Fibonacci Scatter Spiral, category: colorful
- Stefan Abendroth, entry: Seahorse, category: abstract
- Paul Villain, entry: 102 mod 500, category: intricate
Cody 10th Anniversary Winners - Week 1
- The top 3 players for solving most problems in week 1 are Mohammed, Stefan Abendroth, and Hans Bourgeois. Congratulations! Each of you won an Amazon gift card.
- You don’t need to be an expert or spend tons of time to win! As long as you participate, you have the opportunity to win MathWorks T-shirts. Week 1 lucky winners are Meredith Reid and KARUPPASAMYPANDIYAN M.
In Week 2, we’ve added more fun to the contests!
MATLAB Mini Hack 2022:
- Voting started. Cast your votes on your favorite images. Help us show the world the beauty of mathematics by sharing your work with your friends, classmates, or colleagues.
- Toolboxes unlocked. You are able to leverage the Image Processing Toolbox to generate even more interesting images. We will award the best entries leveraging the Image Processing Toolbox.
Cody 10th Anniversary:
- Week 2 special problem group published. Check out MATLAB Fundamentals - Plotting and Visualization. Will you be able to finish the group in week 2?
The contest development team has identified an issue when trying to link your new entries to submissions in the File Exchange. The issue has prevented some users from successfully linking their entries. We have a fix and will be deploying it today at 3pm EST.
Two fun community contests: MATLAB Mini Hack 2022 and Cody 10th Anniversary start today on Oct. 3rd!
Participants across all skill levels are welcome to join! Even if you have limited time, you still have opportunities to win as long as you participate.
Want to challenge yourself and win Amazon gift Cards and limited-edition Badges?
1. MATLAB Mini Hack 2022: Create your best entry (either a new or a remixed entry).
2. Cody 10th Anniversary: Solve your 1st Cody problem today!
If you have any questions about the contest rules or prizes, let us know by replying to this thread.
We hope you enjoy the contests, improve your MATLAB skills, and win prizes! Now, let the party begin!
Uniform spacing and the problem of round-off error
The vector [3 4 5 6 7 8 9] is uniformly spaced with a step size of 1. So is [3 2 1 0 -1 -2] but with a step size of -1.
The vector [1 2 4 8] is not uniformly spaced.
A vector v with uniform spacing has the same finite interval or step size between consecutive elements of the vector. But sometimes round-off error poses a problem in calculating uniformity.
Take, for example, the vector produced by
format shortg
v = linspace(1,9,7)
v = 1x7
1 2.3333 3.6667 5 6.3333 7.6667 9
Linspace produces linearly spaced vectors but the intervals between elements of v, computed by diff(v), are not identical.
dv = diff(v)
dv = 1x6
1.3333 1.3333 1.3333 1.3333 1.3333 1.3333
dv == dv(1)
ans = 1×6 logical array
1 0 0 1 0 1
diff(dv)
ans = 1x5
4.4409e-16 0 -4.4409e-16 8.8818e-16 -8.8818e-16
Some extra steps are therefore necessary to set a tolerance that ignores error introduced by floating point arithmetic.
New in R2022b: isuniform
Determining uniformity of a vector became a whole lot easier in MATLAB R2022b with the new isuniform function.
isuniform returns a logical scalar indicating whether vector v is uniformly spaced within a round-off tolerance and returns the step size (or NaN if v is not uniform).
Let's look at the results for our vector v,
[tf,step] = isuniform(v)
tf = logical
1
step =
1.3333
How about non-uniformly spaced vector?
[tf,step] = isuniform(logspace(1,5,4))
tf = logical
0
step =
NaN
Give it a shot in MATLAB R2022b
- What happens when all elements of v are equal?
- Can you produce a vector with uniform spacing without using colons or linspace?
- What additional steps would be needed to use isuniform with circular data?
References
- isuniform - documentation
- Floating point numbers - documentation
- Floating point numbers - Cleve's Corner (blog)
This article is attached as a live script.
Always or usually. They're fun.
18%
Sometimes, some of them.
7%
Not yet, but probably will some day
25%
Never, and don't plan to.
50%
3937 votos
Two fun community contests: MATLAB Mini Hack 2022 and Cody 10th Anniversary will start on Oct 3rd, 2022. Are you ready for the challenges and big prizes?
How to Play
1. MATLAB Mini Hack 2022 contest:
Use up to 280 characters of MATLAB code to generate an interesting image. New in 2022 contest: You'll be allowed to use functions from File Exchange entries and/or certain MathWorks toolboxes in different weeks.
2. Cody 10th Anniversary contest:
Solve at least 1 Cody problem per day during the 4-week contest period. We will reward participants with the longest streak of days of problem-solving!
Tips to Win
1. MATLAB Mini Hack 2022: Spend time creating your best work (either a new or remixed entry).
2. Cody 10th Anniversary: Make sure you start on the 1st day (Oct 3rd). This is the key if you want to win one of the grand prizes (worth marking your calendar?)
3. Act now: No matter if you want to join either the Mini Hack, Cody, or both. Start planning your strategy today.
Good luck! We hope you are the winner.
We are thrilled to share that more than 400,000 people have subscribed to MATLAB YouTube channel to watch MATLAB and Simulink videos!🎉🙌🥳🎉🙌🥳🎉🙌🥳
The channel started way back in 2006, only one year after YouTube launched. Since then, people have spent more than 2.3 million hours watching our videos. It took us 12 years to reach 100k subscribers, two more years to get to 200k subs, and only 2 years to double that and grow to 400,000!
Did you know that in 2021, there were almost 10 million views to our videos on YouTube?
Thank you again for supporting our community inside and outside MATLAB Central!
You are invited to enter 2 fun community contests: MATLAB Mini Hack 2022 and Cody 10th Anniversary. The contests are designed for you to have fun, win prizes, and sharpen MATLAB skills. Participants across all skill levels are welcome to join!
How to Play
1. MATLAB Mini Hack 2022 contest:
Use up to 280 characters of MATLAB code to generate an interesting image. Sounds challenging? You can still participate by simply voting for the images you love.
2. Cody 10th Anniversary contest:
Solve at least 1 Cody problem per day during the 4-week contest period. We will reward participants with the longest streak of days of problem-solving!
Prizes
You will have opportunities to win compelling prizes, including Amazon gift cards, MathWorks T-shirts, and virtual badges. We will give out both weekly prizes and grand prizes. Check out the rules & prize section on each contest page for details.
Interested in joining? Follow the contests!
Click the ‘Follow the contests’ button to follow/register for the contest. You will get notified when the contests start. After contests start, you will also receive important announcements and prize information.
Grace Hopper Celebration is an event that celebrates the legacy of Grace Hopper who acted as the inspiration for generations of women in tech. My female coworkers in highly accomplished technical roles will be speaking at the event. Come meet, connect and network with them at GHC22.
Congratulations, Walter, for this amazing run!
You hit 100k points on 14th Aug, 2020. So, these 25k points took just over 2 years to earn.
Thank you for your contribution to the community!
MATLAB Central Team
If you are interested in developing algorithms for robotics and autonomous systems using ROS, there is an upcoming livestream just for you.
In this livestream, Jose Avendano Arbelaez and Ronal George will show you how to build and deploy autonomous algorithms using ROS. Using examples, they will show how to interface with ROS networks using publishers and subscribers, build algorithms for mapping, planning and navigation and deploying algorithms as ROS nodes.
Sign up here to get notification when it start streaming at 11:00 am (EDT) on Sep 1 view in your timezone
Congratulations, @Karim for winning the 1st ever Editor's Pick badge awarded for MATLAB Answers, in recoginition of your awesome solution in How to find X and Y coordinates of maximum gap between curves?
This is a new badge we just introduced to recognize awesome answers people contribute and yours was picked for discovering a creative way to solve the problem, and made the solution clear, and reproducible. Thank you so much for setting a high standard for MATLAB Answers and for your ongoing contribution to the community.
MATLAB Central Team
You provided 9717 answers at the acceptance rate of 75.23% and received 3281 votes. Thank you for your contribution to the community!
MATLAB Central Team
Watch live as Brandon Armstrong and Cris LaPierre import, visualize, and compute statistics without writing code in MATLAB.
The first challenge when starting a new project is importing and exploring the data to determine what it contains. This is especially true if your files contain a mix of numeric, text, and categorical data.
MATLAB has many new tools to simplify this process. Using app-based workflows enable you to spend more time investigating and exploring your data and less time troubleshooting code. Importantly, the code required to repeat your analysis is auto-generated so you can apply the same steps to new files and have others reproduce your work.
In MATLAB Answers, oftentimes we see good comments that provide solutions in a question thread. Those comments should really be answers. On the other hand, there are some answers that do not offer solutions. Those answers should actually be comments. The answer/comment issue makes it harder for readers of a question thread to quickly identify useful information. To tackle this issue, the community team just released the MOVE feature!
What can be moved?
Answers and comments can now be moved in 4 ways within the same question thread:
- Change an answer to a comment
- Change an answer with comments to a group of comments
- Change a comment to an answer
- Move a comment
Who can move answers and comments?
New privileges have been awarded to contributors with 2000 reputation points or more. Privileged contributors will see move icons added in the list of actions available for answers and comments.
After an answer or comment is moved, an indication of the move will be displayed with the content.
As always, please let us know your thoughts by leaving a reply below.