Results for
The day and night colours depend on how far the fox has run. Instead of recolouring everything on every frame, I turn the cycle into a small number of steps and only recolour when the step changes:
nn=.5-.5*cos(2*pi*s.dist/3200);
q=round(nn*40);
if ~isequal(s.ax.UserData,q)
s.ax.UserData=q;
% recolour the background, ground, text and obstacles here
end
The current step is stored in the axes UserData, so the check is cheap. Text works the same way. I only set a text string when the new string is different from the old one:
if ~strcmp(s.sct.String,t), s.sct.String=t; end
Setting properties that have not changed still costs time in every frame, so skipping them helps a lot in a game that redraws many times per second.
Check against your code: the first block is simplified from your renderFrame. Your real code also adds +100*(s.st==2) to q so the colours change on the game-over screen, and I left that out to keep the tip simple. The strcmp line is from your score text. Both matc
The day and night colours depend on how far the fox has run. Instead of recolouring everything on every frame, I turn the cycle into a small number of steps and only recolour when the step changes:
nn=.5-.5*cos(2*pi*s.dist/3200);
q=round(nn*40);
if ~isequal(s.ax.UserData,q)
s.ax.UserData=q;
% recolour the background, ground, text and obstacles here
end
The current step is stored in the axes UserData, so the check is cheap. Text works the same way. I only set a text string when the new string is different from the old one:
if ~strcmp(s.sct.String,t), s.sct.String=t; end
Setting properties that have not changed still costs time in every frame, so skipping them helps a lot in a game that redraws many times per second.
All the graphics objects (patches, lines and text) are created one time, when the game starts. After that, the render function only changes their data with set:
set(s.hd,'XData',s.DS{k}+DX,'YData',s.DT{k}+G+s.dy)
Creating new objects on every frame is a common reason MATLAB games feel slow. Updating objects that already exist is much cheaper. To hide an object, I set its data to NaN instead of deleting it:
set(s.ho(m),'XData',NaN,'YData',NaN)
Disclosure: the game code was written with Claude (an AI assistant). I tested the game in MATLAB and checked the details myself.
For the One-button Game Mini Hack, the code limit is 10,000 characters. I made a game called Ember Fox, where a fox runs and a stone guardian chases it, and you have one button. These are the techniques in the code that I found most useful.
Tip 1: Draw pixel-art sprites from text
Each sprite is stored as a grid of characters, where # is a filled pixel and . is empty:
A=['######';'#.##.#';'######';'.####.'];
[X,Y]=spr(A,0.6);
A helper function, spr, turns the grid into rectangles. For each row it uses diff to find where every run of # starts and ends, and each run becomes one rectangle instead of one rectangle per pixel. This keeps the sprite data small and the number of graphics objects low. All the sprites are built once, when the game starts.
If you are as excited as me to play these games but somehow something is stopping you from doing just that, you are at the right place. Follow the steps below and you will be playing in no time (maybe some time depending on your browser, network speed, etc.):
- Click on the game you like the look of (let's say, something that is transformative).

- This will open up its details page with the game code, preview video and the "Play Game" button. Click the video or the button.

- This will open up "MATLAB Drive" in a new browser window with a preview screenshot of a half-played game and a "Run this App" button. Click this button and nothing will seem to happen at first. And nothing will happen at any other subsequent tries. But don't worry, that's why you're here.

- Click on the "entry-×××××" blue hyperlink just above the preview area (underlined in red above). This will take you to a list of two files but hide the crucial blue button. Click on the "Entry×××××.mlapp" file to resurface the blue button.

- With expectant hands, click the "Run this App" button. This time it will reload the "MATLAB Drive" and put it in the mode to run your chosen game.

- Finally, you are where you expected to be in the point 3! Enjoy your game.🥳
Hi everyone,
I made Ember Fox: Outrun the Stone Guardian for the One-button Game Mini Hack. A fox runs forward, and a stone guardian rolls behind it and chases it. You must hop over obstacles to stay ahead.
Play it here: https://www.mathworks.com/matlabcentral/communitycontests/contests/10/entries/16448
(Click Play Game, then Run this App.)
The whole game fits in less than 10,000 characters. Below are the main tricks I used. I hope they help you with your own games.
How the game works
- One button does everything: tap to hop, tap again in the air to dive.
- If you hit an obstacle, the stone guardian gets closer. If it catches you, the game ends.
- Diving onto a flying enemy gives bonus points.
- Power-ups give a shield, slow motion, or push the guardian back.
- Passing obstacles builds a combo multiplier.
- The game gets faster the longer you play, and the sky changes from day to night.
Trick 1: Draw pixel-art sprites from text
I draw each sprite as a grid of characters. A # means a filled pixel:
A=['######';'#.##.#';'######';'.####.'];
[X,Y]=spr(A,0.6);
My helper function spr turns each row into rectangles. It uses diff to find where every run of # starts and ends. One run becomes one rectangle, not one rectangle per pixel. This keeps the number of graphics objects low and the code short.
Trick 2: Create graphics once, then only update them
In init I create every patch, line and text object one time. In renderFrame I only change them with set:
set(s.hd,'XData',s.DS{k}+DX,'YData',s.DT{k}+G+s.dy)
Creating new objects every frame makes a game slow. Updating existing ones is much faster. To hide an object, I set its data to NaN instead of deleting it.
Trick 3: Update only what changed
The day and night colours depend on how far you have run. I turn the cycle into a small number of steps and change the colours only when the step changes:
nn=.5-.5*cos(2*pi*s.dist/3200);
q=round(nn*40);
if ~isequal(s.ax.UserData,q)
s.ax.UserData=q; % change all colours here
end
I do the same for text. I only set the text when the new text is different:
if ~strcmp(h.String,t), h.String=t; end
Trick 4: One button, different actions
The game state decides what the button does:
- On the start or game-over screen, it starts the game.
- On the ground, it makes the fox hop.
- In the air, it makes the fox dive down faster.
This gives the player more choices without adding more buttons.
Trick 5: Smooth difficulty and simple collisions
The speed grows quickly at first, then slows down, so the game stays fair:
s.spd=55+90*(1-exp(-s.sc/900));
Collisions are simple rectangle checks. After a hit, the fox is safe for a short time, so one mistake does not cause many hits in a row.
Trick 6: Fit the character limit
- Use short variable names.
- Use loops and shared code instead of repeating lines.
- Run minihackContest.validate often to check the character count.
Known problem: the game runs smoothly in desktop MATLAB, but it can lag in MATLAB Online. For the best experience, run it on your computer with minihackContest.play.
Thank you for reading! If you have questions or ideas to make it better, please write a comment. I would love to see how you solve these problems in your own games.
Many of us have someone in our lives whose hearing has gradually changed with age. Maybe it's a grandparent who leans in a little closer at the dinner table, or a friend who enjoys a chat more in a quiet cafe than a busy one. For many people, hearing loss over the years becomes part of everyday life.
Behind every hearing instrument is an engineering team trying to help people keep enjoying those conversations.
We'd love to hear from you:
- Has hearing changed the way someone you know enjoys music, conversations or learning?
- If you've worked on audio, hearing aids or wearables, what inspired you, and what made it hard?
Join us at MATLAB Expo Online for the hands-on workshop Designing For Every Ear. Together we will explore the technologies right in MATLAB.
🎸 a whisper becomes a rock concert
33%
🐿️ Wrong frequency mapping
33%
🤐 Signal dropout
0%
🔋 Power regression
33%
3 votes
I have MATLAB R2026b, the MATLAB Agentic Toolkit, and Claude Code installed.
In the first session, I asked Claude (Opus 5.5, High effort) to review the game rules, suggest MATLAB Agentic Toolkit skills, install them inside the project folder, and create a CLAUDE.md file.
In the second session, I asked Claude to create a combat game in which the player controls a simple stick figure wielding a club; clicking makes the figure swing the club. Simple monsters approach the player and drain the player’s health on contact, while hitting a monster with the club eliminates it. The game has an old-school 2D look, with a dark blue, star-filled background and light blue characters.
That's it. You can see result here: CLUB NIGHT
My best score until now is 2060.
Let me know your best score in the comments.

I started my game for this contest, Stack OverDad, one month before the contest began. Dad tells programming jokes at the dinner table, and you have to laugh at the right moment. I was very happy with it. It had a dog, a little brother with a spoon, a window with a sun that goes down, fifty jokes, and many small animations.
Then the contest started, and I read the rules again. One line said: each entry is limited to 10,000 characters of MATLAB code.
My code had more than 70,000 characters.
So, as you can guess, the next hourse were cut, test, cut, test, cut... In this post, I will tell you what I learned on the way (from my AI friend!). Some of it surprised me.
Step 1: Cut What the Player Does Not Feel
For every part of the game, I asked: "Does the player really feel this?"
The dog: cute, but no. The brother: funny, but no. The sunset: nobody looks at the window when Dad tells a joke. Forty jokes: a game only uses ten anyway.
This was the biggest step, and the hardest, because I liked all of these things. But the game did not get worse. It got clearer. After this, my file had about 9,800 characters. I was done!
Step 2: The Surprise
The contest project has a command to check the game before you submit it:
minihackContest.validate
I ran it, and it said:
Validation failed: game.m exceeds the character limit (16145 / 10000, comments excluded).
16,145? My file had 9,800 characters. I counted again. It still had 9,800.
So I opened the validator to see how it counts. This is the line:
charCount = strlength(char(tree2str(mtree(gameFile, '-file'))));
mtree reads the code into a tree, and this removes the comments. Then tree2str writes the code again, in a clean, standard layout. The validator counts that text, not my file.
And the clean layout is not short at all. For example, this one line of mine:
if p,pr(s.T);end
comes back from tree2str like this:
if p
pr( s.T );
end
Every statement gets its own line. Every line gets indentation. Every f(a,b) becomes f( a, b ), and every [1 2 3] becomes [ 1, 2, 3 ]. My short style was not short anymore.
The good news: now I knew the real rule, so I could play by it.
Step 3: What Is Cheap and What Is Expensive
- Expensive: many statements, deep nesting, and long lists of numbers.
- Cheap: text inside a string. tree2str does not change a string at all.
So the plan was: fewer statements, less nesting, and move numbers into strings.
Example 1: Many Values in One Statement
s.st = 3;
s.t0 = t;
s.la = -1;
becomes one statement with deal:
[s.st, s.t0, s.la] = deal(3, t, -1);
Example 2: A Small if Without if
if n == 1
s.fl = "TEN?!";
end
With logical indexing, it is one line. If the condition is false, nothing changes:
s.fl(n == 1) = "TEN?!";
Example 3: Many Strings in One String
A list like ["PERFECT!", "GOOD!", "TOO LATE..."] pays for every ", ". One string with a separator is cheaper:
B = split("PERFECT!|GOOD!|TOO LATE...", "|");
All fifteen jokes are now one string too.
Example 4: Numbers Inside a String
This was the biggest trick. My scene (the table, the chairs, Dad, the family) is made of rectangles, ellipses, and polygons. That is hundreds of numbers.
So I stored each number as one character in a string. A character is really a number (its code), so I can turn it back:
v = double(char(z))/20 - 1025; % every character of z becomes one number again
I chose codes from a big block of normal, printable characters. They look like Chinese characters, but they are not words. I only use their codes. One small loop reads the string and draws all the shapes with patch. Now the whole scene costs about one character per number.
One warning from my own mistake: use double(char(z)), not double(z). If z is a string, double(z) gives NaN. My first test showed an empty table because of this.
I kept the readable list of shapes in a separate file, and it writes the packed strings for me.
I Had Help
I worked with an AI assistant the whole way. It read the validator with me, tested many small ideas fast, measured which part of the code cost the most, and rewrote code again and again without getting tired.
But the AI did not decide what the game is. It could tell me that the dog costs 1,700 characters. It could not tell me if the dog is worth it. Every "keep" or "cut" was my choice. I think this is the best way to work with AI: let it do the heavy lifting, and keep the decisions for yourself.
The Result
The validator now says 9,936 characters. The game still has Dad, THE LOOK, Mom's warnings, the family walking out, the ranks, and fifteen jokes.
My advice: run minihackContest.validate early. Do not count the characters yourself, because the validator does not count your file. It counts the clean version of your file.
I hope you have found this helpful. Thank you for reading.
Recently, I encountered an issue where solve returned no solution for a system of equations, even though the system obviously has solutions. This can be easy to overlook.
For example:
syms a b c x
equs = [a*x^2+b*x+c==0;
a==1];
St = solve(equs,x)
St is returned as an empty set, suggesting that there is no solution???
However, since a is constrained by the equation a == 1, the correct way is:
S = solve(equs,[x,a])
disp(S.x)
disp(S.a)
Here, a must also be included in the list of variables to solve for. Only then will solve treat a as an unknown, apply the constraint a == 1, and substitute it into the equation during the solving process.
symvar(equs)
Based on the output of the symvar function, a is already identified as one of the symbolic variables (unknowns) in the system of equations. However, the actual behavior of solve appears to contradict this expectation. In practice, a must still be explicitly included in the variable list passed to solve; otherwise, it is treated as a symbolic parameter rather than a variable to be solved for.
Takeaway: When using solve for a system of equations, any symbol that appears in the equations and is constrained by additional equations (such as a == 1) should generally be included in the variable list. Otherwise, solve may treat it as a symbolic parameter rather than an unknown, which can lead to an empty solution set or unexpected results.
Am I missing something here? I'd love to hear your thoughts.
Hi everyone! I am one of the MATLAB Product Managers supporting MATLAB Projects and MATLAB Package Manager. R2026b was a major update for both of these tools, and we are excited to show how you can build software in MATLAB and Simulink using modern software development tools. There is a track session and a workshop that you can attend. Come learn about the simpler matlab.toml file and how your code can finally depend on packages. You can see a preview here:

MATLAB EXPO Online 2026 is almost here! With 40+ sessions across five technical tracks plus nine live, hands-on workshops, now is a great time to explore the agenda and decide what you don’t want to miss.
Whether you’re interested in AI and Agentic AI, Model-Based Design, electrification, robotics and autonomous systems, or Cloud and DevOps, there’s plenty to choose from.
💬 What session or workshop is already on your must-see list? Share it in the comments so others can discover it too!
As a long-standing request from users, we are happy to announce that HDFql now supports MATLAB for managing HDF5 and MAT files.
In short, HDFql (Hierarchical Data Formal query language) is the first high-level, declarative language for managing HDF5 or MAT data. Designed to be as simple and powerful as SQL, it dramatically reduces the learning effort and time required to work with HDF5. With its intuitive syntax, HDFql provides a clean interface for reading and writing HDF5 data across programming languages (C, C++, Java, Python, C#, Fortran, R, and now MATLAB) and platforms (Windows, Linux, and macOS). In addition, HDFql is based on a flexible parallel architecture that transparently leverages available cores and, in MPI clusters, nodes to efficiently process large volumes of data.
Key benefits of HDFql include enabling users to replace dozens of lines of complex HDF5 code with just a few lines of simple code, helping AI models generate better code using far fewer tokens, and making AI-generated code easier for humans to review.
Happy coding, prompting, or reviewing with HDFql in MATLAB!
I am frequently facing issue with the onramp training of not proceeding to the next task or section, even after successfully completion of the current task or complete section.
Agentic AI is changing how engineers work. Join Jason Ghidella to see how AI agents can help accelerate coding, modeling, requirements generation, testing, and validation with MATLAB and Simulink, while maintaining the rigor needed to trust the results.
See real-world demonstrations spanning app building, system modeling, simulation, test generation, and system validation, and discover what the future of AI-powered engineering looks like.
The Ran In tag still shows R2026a on Answers and Discussions (as does the Executing In popup), even though both are actually running R2026b.
This seems to be always be an issue whenver the site updates to the latest release. Seems like it should be pretty straightforward to update those message at the same time the underlying release is updated. Or am I underestimating the complexity of that task?
matlabRelease
What if MATLAB could show you not only the final output, but also how your code reaches that result?
Imagine an interactive tool that visualizes variable changes, function calls, matrix transformations, and execution flow as a program runs. Engineers could watch algorithms evolve, identify unexpected behavior, and understand complex simulations through live visualizations.
The idea is to build a Live MATLAB Execution Explorer that combines code tracing, variable timelines, and 3D engineering simulations in one interface.
From debugging control systems to teaching numerical methods, this could transform how students, researchers, and engineers interact with code.
The challenge? Capturing execution data efficiently without significantly affecting performance.
The vision: Turn programming from something we read into something we can see, explore, and understand.
#MATLAB #Simulink #EngineeringInnovation #Simulation #DeveloperTools
I recently had an idea for a side project: building an app/extension that can interactively follow simulations and visualise the live flow of code execution.
For this, I would need access to variables, datasets, and the function call stack during execution, ideally without interfering with the actual code execution.
However, I found that MATLAB's current architecture makes this difficult, as the entire application runs in a single thread and there are no publicly exposed APIs to access runtime variables without interrupting execution.
Can anyone suggest a possible workaround or an alternative approach to achieve this?
I recently had an idea for a side project: building an app/extension that can interactively follow simulations and visualise the live flow of code execution.
For this, I would need access to variables, datasets, and the function call stack during execution, ideally without interfering with the actual code execution.
However, I found that MATLAB's current architecture makes this difficult, as the entire application runs in a single thread and there are no publicly exposed APIs to access runtime variables without interrupting execution.
Can anyone suggest a possible workaround or an alternative approach to achieve this?
Ready to explore the latest advancements in engineering and science with MATLAB and Simulink?
MATLAB EXPO Online 2026 is taking place November 4-5, 2026, and registration is now open. Join engineers, researchers, educators, and industry leaders from around the world for two days of technical presentations, hands-on workshops, customer success stories, and live Q&A sessions.
What to Expect
✅ 40+ interactive sessions featuring MathWorks experts and industry leaders
✅ 5 technical tracks, including AI and Agentic AI, Digital Engineering and Model-Based Design, Electrification and Energy Systems, Robotics and Autonomous Systems, and Cloud, CI/CD and DevOps
✅ 9 live, 90-minute hands-on workshops using MATLAB Online and Simulink Online
✅ Keynotes on emerging engineering trends and the latest MATLAB and Simulink capabilities
✅ Opportunities to connect with experts and peers from around the globe through live Q&A and networking activities
Whether you're just getting started or are an experienced MATLAB and Simulink user, you'll find content tailored to a range of experience levels and application areas.
Participation is free, but registration is required. Reserve your spot and start building your personalized agenda today.
What session or topic are you most excited to explore this year? Let us know in the comments!