Absolutely!
65%
Probably
8%
Sometimes yes, sometimes no
8%
Unlikely
15%
Never!
4%
26 voti
A miniature GPT language model MATLAB Live Script
Duncan Carlsmith, Department of Physics, University of Wisconsin-Madison
I have built many MATLAB Live Scripts that take some piece of physics, computation, or machine learning apart so a student can see how it works. The newest one builds, trains, and runs a small GPT language model and was built with AI assistance and may interest readers of this forum.
The model is a MATLAB implementation modeled on nanoGPT, a compact GPT (Generative Pre-trained Transformer) written in Python by Andrej Karpathy and released under the MIT license. This small model is a GPT in each respect: it is generative, producing text one character at a time rather than classifying text; it is pre-trained, trained once on a body of text so that the trained weights can then be reused; and it is a transformer, built from the stack of masked self-attention and feed-forward layers described in more detail in the Live Script Background section. The script trains a character-level model with about 112,000 parameters, two transformer blocks, and one or four attention heads. It is trained on an approximately one-million-character corpus of Shakespeare in roughly twenty minutes on a laptop and, remarkably, generates Shakespeare-flavored text one character at a time. The model parameter count and training corpus pale in comparison to frontier models with estimated parameter counts of order one trillion trained and tens of trillions of tokens. The aim of the Live Script is explanation, not performance.
MATLAB implementation
The training script is vectorized: weights are created as dlarray objects, the loss is computed under dlfeval, and a single call to dlgradient returns the gradient with respect to every weight. The attention of a whole batch of sequences is computed in one pagemtimes call rather than a loop. The autodiff and the batched array arithmetic are what make training on a laptop practical.
A note on the development
The script, the model class, and the trainer were built with Claude (Anthropic), starting with the Python and working with MATLAB R2026a on my own machine through an ngrok command server.
Try this and challenge options
The script ships with the Shakespeare text and one pre-trained model. It also includes an optional section that downloads three public-domain novels from Project Gutenberg — Conan Doyle, Wells, Austen — strips the license boilerplate, and aggregates them into a single corpus, so a student can train a model that writes in a different voice. A model trained on novels does not sound like one trained on Shakespeare, and that difference is the most direct lesson the script offers about what these models actually learn. Several challenges are offered to expand the model and the demonstration.
The submission is on the MATLAB Central File Exchange: Duncan Carlsmith (2026). nanoGPT Explorer (https://www.mathworks.com/matlabcentral/fileexchange/183953-nanogpt-explorer), MATLAB Central File Exchange. Retrieved May 24, 2026.
Conflict of interest
The author declares he has no financial interest in MathWorks or Anthropic. This article is informational and does not constitute an endorsement by the University of Wisconsin-Madison of any vendor or product. Claude is a trademark of Anthropic. MATLAB is a trademark of MathWorks.
I have a LORA node up-linking data to a Thingspeak channel via The Things Network (TTN). Sometimes it stops sending data and I reboot it by logging into my console on TTN and sending a re-boot down-link message to the node. Is there any way I can transmit a downlink message to the node direct from Thinkspeak?
Walter Roberson
Walter Roberson
Ultima attività il 23 Maggio 2026 alle 7:44

"As of January 1, 2026, Perpetual Student and Home offerings have been sunset and replaced with new Annual Subscription Student and Home offerings."
So, Perpetual licenses for Student and Home versions are no more. Also, the ability for Student and Home to license just MATLAB by itself has been removed.
The new offering for Students is $US119 per year with no possibility of renewing through a Software Maintenance Service type offering. That $US119 covers the Student Suite of MATLAB and Simulink and 11 other toolboxes. Before, the perpetual license was $US99... and was a perpetual license, so if (for example) you bought it in second year you could use it in third and fourth year for no additional cost. $US99 once, or $US99 + $US35*2 = $US169 (if you took SMS for 2 years) has now been replaced by $US119 * 3 = $US357 (assuming 3 years use.)
The new offering for Home is $US165 per year for the Suite (MATLAB + 12 common toolboxes.) This is a less expensive than the previous $US150 + $US49 per toolbox if you had a use for those toolboxes . Except the previous price was a perpetual license. It seems to me to be more likely that Home users would have a use for the license for extended periods, compared to the Student license (Student licenses were perpetual licenses but were only valid while you were enrolled in degree granting instituations.)
Unfortunately, I do not presently recall the (former) price for SMS for the Home license. It might be the case that by the time you added up SMS for base MATLAB and the 12 toolboxes, that you were pretty much approaching $US165 per year anyhow... if you needed those toolboxes and were willing to pay for SMS.
But any way you look at it, the price for the Student version has effectively gone way up. I think this is a bad move, that will discourage students from purchasing MATLAB in any given year, unless they need it for courses. No (well, not much) more students buying MATLAB with the intent to explore it, knowing that it would still be available to them when it came time for their courses.
I submitted a Matlab support case but posting this publicly to hopefully save people some trouble and see if anyone has ideas.
After upgrading my workstation from Ubuntu 25.10 to Ubuntu 26.04 LTS, MATLAB GUI consistently prints this terminal error on shutdown:
free(): chunks in smallbin corrupted
MATLAB appears to run normally, but closing the GUI takes a long time and sometimes produces crash dumps. The terminal error occurs every time I close the GUI, but crash dumps are intermittent. I attached one R2026a crash dump. I had zero issues on Ubuntu 25.10.
Affected versions:
  • MATLAB R2026a
  • MATLAB R2025b
  • I suspect any 'new desktop' version
System:
  • Ubuntu 26.04 LTS
  • AMD EPYC 7443P
  • NVIDIA RTX 3090
  • Ubuntu 26.04 default NVIDIA driver: nvidia-driver-595-open, 595.58.03
  • NVIDIA module path: /lib/modules/7.0.0-14-generic/kernel/nvidia-595-open/nvidia.ko
  • glibc 2.43
Important note: the error first occurred with a clean MathWorks MATLAB installation before installing the Ubuntu/Debian `matlab-support` package. I later tested after installing `matlab-support`, which I understand modifies/renames some MATLAB-bundled libraries so MATLAB uses selected system libraries instead. The same shutdown error occurs both before and after applying `matlab-support`. This suggests the issue is not caused solely by the Debian/Ubuntu `matlab-support` integration or solely by one of the libraries it substitutes.
The attached crash dump shows abort/free() heap corruption detected in libc, but the higher-level stack includes MATLAB libraries such as:
The issue appears GUI-specific. Using these startup flags shut down cleanly:
  • matlab -batch
  • matlab -nodesktop
  • matlab -nodisplay
The shutdown error still occurs with these startup flags:
  • normal GUI launch
  • -nosplash
  • -nojvm
  • -softwareopengl
  • -cefdisablegpu
The issue also persists after:
  • renaming/resetting ~/.matlab/R2026a and ~/.MathWorks/R2026a
  • launching with a clean environment without LD_LIBRARY_PATH, LD_PRELOAD, MATLAB_JAVA, JAVA_HOME, JRE_HOME, etc.
  • testing a new Ubuntu user account
  • testing Ubuntu/GNOME, GNOME, and Xfce X11 sessions
  • testing NO_AT_BRIDGE=1 and GTK_USE_PORTAL=0
  • temporarily moving ~/.MathWorks/ServiceHost
  • testing GLIBC_TUNABLES=glibc.malloc.tcache_count=0
  • trying to capture a system coredump with ulimit -c unlimited / coredumpctl; no system coredump was produced
Because R2025b and R2026a are both affected, terminal-only modes exit cleanly, the problem occurs across GNOME/Wayland and Xfce/X11, and the error occurred on a clean MATLAB install before any `matlab-support` modifications, this appears related to MATLAB GUI shutdown on Ubuntu 26.04 / glibc 2.43 rather than a corrupted MATLAB preference folder, a single desktop session, or the Ubuntu `matlab-support` package.
Example crash dump:
Walter Roberson
Walter Roberson
Ultima attività il 22 Maggio 2026 alle 4:03

talks about how GeForce has become deprioritized by Nvidia, and
The chatter from the grapevine is that we won't see any new GPUs from Nvidia this
year at all — not one — and that's very rare (in fact it hasn't happened in three
decades). This is because Nvidia needs all the chips it can get — and perhaps more
to the point, all the video RAM — for AI graphics cards which are far more
profitable than consumer models.
Soon, Mathworks will be facing a choice: continue to support only expensive Nvidia AI offerings -- or diversify to support alternative GPUs as well.
By the way: Nvidia AI units cost $US7.8 million dollars. https://www.tomshardware.com/tech-industry/artificial-intelligence/nvidias-memory-costs-soar-485-percent-latest-ai-systems-now-cost-usd7-8-million-to-build-memory-now-comprises-25-percent-of-the-total-cost-rubin-gpus-a-mere-usd50-000-apiece
Which alternative GPUs would you most like to see supported?
  • Unfortunately, I hear that Apple provides poor support for information on really using their "silicon" GPUs in any way other than Apple's pre-packaged computation libraries. The Apple attitude is apparently that anything that is not already nailed down by documentation is fair game for changing in the future, and that documenting how the GPUs really work would constitute nailing them down, supposedly "destroying" Apple's creativity. Exception: Apple is known to work with major gaming studios (but only the major ones.)
  • The Apple silicon series of GPU does not provide any 64 bit operations, so 64 bit support would require emulating 64 bits in software. Nvidia is famous for internally implementing 64 bit support in terms of 32 bit operations, at 1:32 of the speed -- but on the other hand select Nvidia devices operate 64 bit operations at 1:24 or even 1:8 (a small number of devices) through hardware acceleration units. People who need 64 bit operations have the option of shopping very carefully in Nvidia's line to get faster 64 bit processing.
  • OpenCL sounds cool and "open". Unfortunately it turns out that a lot of OpenCL operations are optional, so efficient OpenCL libraries would need to be tuned to the exact hardware series.
  • OpenCL is not supported on semi-recent MacOS Intel or Apple Silicon series
  • I seem to recall hearing that OpenCL is no longer supported by Nvidia either
Background: I've been using Claude Code with the MATLAB MCP Core Server and Simulink Agentic Toolkit for powertrain simulation work — building PMSM FOC controllers, Simscape thermal models, and suspension systems. After a few sessions I noticed a large fraction of my context window was being consumed by output that's useful to a human but not to an LLM: aligned whos tables, repeated solver warnings (one per timestep), deep call stacks with HTML hyperlinks, Simulink build logs, etc.
What I built: A transparent Python stdio proxy that sits between Claude Code and matlab-mcp-core-server. It intercepts tool responses and applies 14 MATLAB/Simulink/Simscape-specific compression rules before the output reaches Claude's context window. Requests are never touched — only responses.
Example reductions:
  • whos variable table → 74% reduction (1,800 chars → 189 chars)
  • Repeated solver warnings (×10 RCOND warnings) → 71% reduction
  • Large array auto-display (1000-row vector) → 85% reduction
  • Simulink build log → 56% reduction
  • DOE progress loop (55 points) → 79% reduction
  • Session average: 48–66% reduction
It also fixes the simulink session attach problem. Without --initialize-matlab-on-startup=true on the matlab server, the simulink server's 30-second discovery window expires before MATLAB is ready. The proxy config includes this flag and documents why it's necessary (root cause traced through server logs).
Validated on: A 2-DOF Simscape quarter-car active suspension model built entirely via model_edit from the SATK — active PD controller achieved 61.7% lower peak chassis velocity and settled 34% faster than passive.
Includes 37 unit tests, full HTML documentation, and the validated Simscape model. Would be interested to hear if others have run into the same output verbosity issues and what workarounds you've tried.
Mike Croucher
Mike Croucher
Ultima attività il 20 Maggio 2026 alle 14:53

Short version: MathWorks have released the MATLAB Agentic Toolkit which will significantly improve the life of anyone who is using MATLAB and Simulink with agentic AI systems such as Claude Code or OpenAI Codex. Go and get it from here: https://github.com/matlab/matlab-agentic-toolkit
Prototyping MATLAB code in Claude's container with Octave
Duncan Carlsmith, Department of Physics, University of Wisconsin-Madison
Simulated rigid molecules trajectories
Fig. 1: Simulated rigid molecules trajectories
When working with AI to develop MATLAB code for a chaotic-dynamics simulator, I discovered a useful workflow trick: Claude's container ships with GNU Octave. Claude can write .m files and execute them directly, as it can Python, getting fast feedback before you ever push to your local system. The related workflow described here may be possible using any agentic AI offering access to Octave.
The code simulates a classical 2D monatomic or diatomic (rigid or flexible) molecule undergoing a volume compression and compares the adiabatic coefficient in the simulation to the predictions of the ideal gas model and classical thermodynamics, assuming equipartition of energy between the translational, rotational, and vibrational degrees of freedom. Energy is injected by the moving container wall to various degrees of freedom during collisions, and the goal is to see how well the degrees of freedom thermalize through wall collisions alone without intermolecular collisions, and to study wall shape effects. The simulation uses an impact dynamics model for the collisions and tightly controlled state propagation.
My setup includes Claude, an ngrok link to speed up file transfer between a chat container and my local file system, and MATLAB MCP, enabling Claude to push and run MATLAB R2025b and collect output. I decided to first develop in Python entirely in the container, telling Claude to think in advance about porting to MATLAB. This approach allowed Claude to debug quite a package of Python code without the overhead of transferring code and results to and from my system. At various stages, we backed up the Python along with status reports to my filesystem in case the chat failed.
The next stage was to port to MATLAB. When Claude just launched into testing the MATLAB code with Octave in its container, I was taken aback - I hadn’t ever thought of that or known it was a built-in option. We proceeded to make floating-point comparisons of the Python and Octave simulation outputs (which agreed to ~1e-13) to debug the Octave. Finally, we simply transferred about 30 files of Octave/MATLAB code to my filesystem and verified it worked.
The version problem
Claude's container runs Octave 8.4.0, released in late 2023. The current Octave is 11.1.0, released February 2026. Octave is actively maintained, with three or four releases per year. Newer classdef improvements, advances with sparse/diagonal matrices, and various function flags available in 11.1 are lacking in 8.4. For my simulation code, none of this turned out to matter.
Why not just upgrade?
According to Claude, “the container is Ubuntu 24.04 LTS, and its repositories only offer 8.4.0. A standard apt-get install chain failed in interesting ways — Ubuntu's security archive sometimes drops point-version .deb files that the local package index still references, breaking unrelated dependency chains. The openssh-client package got 404'd, which cascaded through openmpi-bin, stopping the install.” Claude suggested “building from source (45+ minutes of compile, plus C++20 and Fortran toolchains), a third-party PPA, or Flatpak (which isn't installed).” My answer was: “I don’t understand all that gobbledygook. Live with 8.4, but write code that will also work in modern MATLAB.”
Octave 8.4 handles array operations, slicing, broadcasting, structs, .mat file I/O via load/save, anonymous functions, fzero and other root-finders, ODE solvers, +package/ namespace folders, sparse matrices, and basic plotting. For our project — a wall-collision simulator with a Forest-Ruth symplectic integrator and Brent's method root-finding — every line of Python code ran identically in MATLAB. The numerical answers differed at the floating-point-precision level (Octave's fzero and MATLAB's fzero round slightly differently, apparently).
Gotchas
A few pitfalls were encountered that you might note if you try this workflow.
1. Nested function definitions inside loops or after executable code
Octave is relaxed about where you put helper function blocks. MATLAB R2025b is strict: local functions go at the end of a file, not inside another function body or — fatally — inside a for loop. I had written:
for i = 1:n
if condition
function f = f_trial(t) % LEGAL in Octave, ERROR in MATLAB
...
end
root = fzero(@f_trial, ...);
end
end
MATLAB rejected this with "Function definition is misplaced or improperly nested." The fix is to move helpers to the end of the file as proper local functions, and use anonymous functions for closures over loop-local variables:
for i = 1:n
if condition
r0 = snapshot_r; % capture in loop scope
f_trial = @(t) helper(t, r0, ...); % captures at creation
root = fzero(f_trial, ...);
end
end
function f = helper(t, r0, ...) % at file end
...
end
2. MATLAB's arguments...end validation block
A MATLAB feature for argument typing and defaults is unsupported in Octave. The modern MATLAB style:
function log = simulate(state, schedule, opts)
arguments
state struct
schedule struct
opts.N_max (1,1) double = 200000
opts.verbose (1,1) logical = false
end
% opts.N_max and opts.verbose available, types and sizes validated
...
end
Octave's parser doesn't recognize the arguments keyword. The fallback is old-style manual parsing:
function log = simulate(state, schedule, varargin)
N_max = 200000;
verbose = false;
for k = 1:2:numel(varargin)
switch varargin{k}
case 'N_max', N_max = varargin{k+1};
case 'verbose', verbose = varargin{k+1};
end
end
...
end
3. Hardcoded paths
Not an Octave-specific problem, but Claude's container has different paths than your local filesystem. Resolve data files relative to the script:
this_dir = fileparts(mfilename('fullpath'));
data = load(fullfile(this_dir, 'comparison', 'data.mat'));
4. Variable name collision
Again, not an Octave-specific problem, but variable name collisions (with Python objects in your workspace, or stale function caches after Claude pushes a new file) can cause confusing errors. clear all resets both.
5. Floating-point differences that get amplified
Octave's fzero and MATLAB's fzero round differently. In chaotic dynamics, such differences can be amplified. For the simulator we built, the same flexible molecule initial condition ran to 215 collisions in Octave and 226 in MATLAB R2025b — identical physics, different trajectories. That such tiny differences could be amplified in this simulation was verified with tests in the three languages - Python, Octave, and MATLAB.
Speed
Claude pointed out that performance varies with language and offered a comparison for a flexible molecule example with ~215-230 wall collisions): Python (CPython 3 + NumPy + scipy.brentq), ~3.3 s, 1×;MATLAB R2025b, 0.5 s, 0.15× (6.6x faster than Python); Octave 8.4 in Claude's container, ~10 s, 3× (3x slower than Python).
In this most challenging case, the integrator has to step between collisions to properly simulate the coupled rotations and vibrations. The 20x speed improvement of MATLAB over Octave might be due to the MATLAB JIT.
Conclusion
When I first started developing MATLAB Live Scripts for physics education, I suggested Octave as an open-source alternative for those educators who had no MATLAB site license. Knowing the limitations of Octave and not knowing if its development would continue, I have not limited myself to Octave-compatible code. I am nonetheless tickled that this workflow succeeded. I might have skipped the Python prototype for this project. Of course, for those projects featuring MATLAB toolboxes not supported by Octave or Python, prototyping MATLAB code in these languages is more complicated.
Conflict of interest
The author declares he has no financial interest in Mathworks or Anthropic. This article is informational and does not constitute an endorsement by the University of Wisconsin-Madison of any vendor or product. Claude is a trademark of Anthropic. MATLAB is a trademark of Mathworks.
Hello and a warm welcome to everyone! We're excited to have you in the Cody Discussion Channel. To ensure the best possible experience for everyone, it's important to understand the types of content that are most suitable for this channel.
Content that belongs in the Cody Discussion Channel:
  • Tips & tricks: Discuss strategies for solving Cody problems that you've found effective.
  • Ideas or suggestions for improvement: Have thoughts on how to make Cody better? We'd love to hear them.
  • Issues: Encountering difficulties or bugs with Cody? Let us know so we can address them.
  • Requests for guidance: Stuck on a Cody problem? Ask for advice or hints, but make sure to show your efforts in attempting to solve the problem first.
  • General discussions: Anything else related to Cody that doesn't fit into the above categories.
Content that does not belong in the Cody Discussion Channel:
  • Comments on specific Cody problems: Examples include unclear problem descriptions or incorrect testing suites.
  • Comments on specific Cody solutions: For example, you find a solution creative or helpful.
Please direct such comments to the Comments section on the problem or solution page itself.
We hope the Cody discussion channel becomes a vibrant space for sharing expertise, learning new skills, and connecting with others.
Kenneth Davis
Kenneth Davis
Ultima attività il 15 Maggio 2026 alle 23:13

I am a bit neurotic about getting things "just right" and I would really like the ability to resize panels on the desktop to predefined default configurations. I know that I can set up the panels by hand and save them, but I'd like to be able to automatically set a 3 column layout to 25%-50%-25% or perhaps 33%-34%-33% This would be somewhat like the snap feature in windows shown here: https://support.microsoft.com/en-us/windows/snap-your-windows-885a9b1e-a983-a3b1-16cd-c531795e6241. This wouldn't have to preclude setting them by hand but it would offer an automated alternative.
If this feature already exists, perhaps someone can point me to it.
Walter Roberson
Walter Roberson
Ultima attività il 15 Maggio 2026 alle 18:30

We are nearly at the anniversary of The Great Outage, May 19 2025 to May 27 2025. At the time, many Mathworks services were down due to a ransomware attack.
Some service was restored by May 21 2025 but it went down again after that.
I see some indication that some features such as @doc took even longer to restore than May 27th.
The outage came as MATLAB Answers usage was already declining a fair bit due to widespread AI use, and unfortunately some of the existing traffic just never came back.
Walter Roberson
Walter Roberson
Ultima attività il 15 Maggio 2026 alle 8:39

As of R2026a, only the Apple Silicon series is supported.
My Intel Mac dates to June 2020; the M1 series was released in November 2020.
So we got only 5 years of use before MATLAB gave up on us. 2 years (R2023b) since the native M1 version was introduced.
I don't exactly have a spare $2500 to spend on a new iMac -- especially not for one that has a maximum of 32 gigabytes of memory when my current system has 128 gigabytes of memory.
I remain disappointed that Mathworks did not continue Intel support for longer.
We’re excited to share that Cleve Moler, creator of MATLAB, has been elected to the U.S. National Academy of Sciences—one of the highest honors in science.
This recognition celebrates Cleve’s groundbreaking contributions to numerical computing and his lasting impact on researchers, educators, and engineers around the world. From advancing numerical linear algebra to making powerful computation more accessible through MATLAB, his work has shaped how science and engineering are done today.
Please join us in congratulating Cleve on this well‑deserved honor!
🔗 Learn more about the 2026 NAS election
Have been using Thingspeak for a few years, suddenly I get this message relating to one of my Matlab analysis scripts, which has run for years:
Error Message:
Unrecognized function or variable 'cusum'. cusum requires Signal Processing Toolbox.
What has changed to cause this error - I've done nothing!
Zhaoxu Liu / slandarer
Zhaoxu Liu / slandarer
Ultima attività il 11 Maggio 2026 alle 0:01

Generate a 3D visualization of carnation flowers
with sepals and stems for celebrating Mother's Day 2026.
function carnation
% CARNATION Generate a 3D visualization of carnation flowers with sepals and stems.
% This code is authored by Zhaoxu Liu / slandarer
% for the purpose of celebrating Mother's Day 2026.
% =========================================================================
% Zhaoxu Liu / slandarer (2026). carnation for Mother's Day
% (https://www.mathworks.com/matlabcentral/fileexchange/183838-carnation-for-mother-s-day),
% MATLAB Central File Exchange. Retrieved May 9, 2026.
% Create figure and axes / 创建图窗及坐标区域
fig = figure('Units','normalized', 'Position',[.3,.1,.4,.8],'Color',[244,234,225]./255);
axes('Parent',fig, 'NextPlot','add', 'DataAspectRatio',[1,1,1],...
'View',[-64, 5.5], 'Position',[0,-.15,1,1], 'Color',[244,234,225]./255, ...
'XColor','none', 'YColor','none', 'ZColor','none');
annotation("textbox", [.05, .8, .9, .2], "String", {"Happy"; "Mother's Day"}, ...
'FontName','Segoe Script', 'FontSize',52, 'FontWeight','bold', 'EdgeColor','none', ...
'HorizontalAlignment','center', 'VerticalAlignment','middle', 'Color',[97,40,20]./255);
xx = linspace(0, 1, 100);
tt = linspace(0, 1, 1e4);
[X, P] = meshgrid(xx, tt);
T1 = P*20*pi;
C1 = 1 - (1 - mod(3.6*T1/pi, 2)).^4./2; % Petal profile / 花瓣形状
S1 = (sin(50*T1)/150 + sin(10*T1)/30).*min(1, max(0, (X - .85)/.1)); % Edge serration / 边缘褶皱和锯齿
Y1 = (- (X.*1.2 - .5).^5.*32 - 1)./15.*P; % Petal curvature / 花瓣弧度
% Petal shape and serration modeling + rotating the planar petal to tilt it
% 花瓣形状和锯齿塑造 + 转动平躺的花瓣令其倾斜
R1 = (C1 + S1).*(X.*sin(P) - Y1.*cos(P))./(P + .5);
H1 = (C1 + S1).*(X.*cos(P) + Y1.*sin(P));
% Convert radius to Cartesian coordinates / 将半径映射为X,Y坐标
X1 = R1.*cos(T1);
Y1 = R1.*sin(T1);
% Colormap for carnation petals / 康乃馨配色
CList1 = [208, 62, 23; 221,146,121; 229,201,202; 233,219,222; 237,223,225]./255;
CMat1 = zeros(1e4, 100, 3);
CMat1(:, :, 1) = repmat(interp1(linspace(0, 1, size(CList1, 1)), CList1(:, 1), linspace(0, 1, 100)), [1e4, 1]);
CMat1(:, :, 2) = repmat(interp1(linspace(0, 1, size(CList1, 1)), CList1(:, 2), linspace(0, 1, 100)), [1e4, 1]);
CMat1(:, :, 3) = repmat(interp1(linspace(0, 1, size(CList1, 1)), CList1(:, 3), linspace(0, 1, 100)), [1e4, 1]);
% Darken edges / 边缘的深色
for i = 1:1e4
tNum = randi([98, 100]);
CMat1(i, tNum:end, 1) = 212./255;
CMat1(i, tNum:end, 2) = 87./255;
CMat1(i, tNum:end, 3) = 113./255;
end
% Rotation matrices / 旋转矩阵
Rx = @(rx) [1, 0, 0; 0, cos(rx), -sin(rx); 0, sin(rx), cos(rx)];
Rz = @(yz) [cos(yz), - sin(yz), 0; sin(yz), cos(yz), 0; 0, 0, 1];
Rx1 = Rx(pi/6); Rz1 = Rz(0);
% Render flower / 绘制康乃馨
surface(X1, Y1, H1 + .3, 'CData',CMat1, 'EdgeAlpha',0.1, 'EdgeColor',[224,39,39]./255, 'FaceColor','interp')
[U1, V1, W1] = matRotate(X1, Y1, H1 + .3, Rx1);
surface(U1 + .7, V1 - .7, W1 - .6, 'CData',CMat1, 'EdgeAlpha',0.1, 'EdgeColor',[224,39,39]./255, 'FaceColor','interp')
% Following the same method as before,
% the profile is designed with four serrated cycles to simulate the four sepals.
% 还是之前的方法,不过让轮廓有4个锯齿状周期来模拟四片花萼
% Sepals generation with 4-lobed pattern / 生成四片花萼(带4个锯齿状周期)
[X, T] = meshgrid(linspace(0, 1, 100), linspace(0, 1, 100).*2*pi);
P2 = T.*0 + pi/8;
C2 = .5 + (.5 - abs(mod(T, pi/2)/pi*2 - .5))*.4;
Y2 = (- (X.*1 - .5).^7.*128 - 1)./15 - .1;
R2 = C2.*(X.*sin(P2) - Y2.*cos(P2));
H2 = C2.*(X.*cos(P2) + Y2.*sin(P2));
X2 = R2.*cos(T);
Y2 = R2.*sin(T);
% Rotate by 90 degrees around the z-axis
% and reduce the size to render the four smaller sepals.
% 绕z轴旋转90度且减小其大小,绘制四片小花萼
% Smaller sepal layer / 绘制四片小花萼(第二层)
P3 = T.*0 + pi/10;
C3 = .3 + (.5 - abs(mod(T + pi/4, pi/2)/pi*2 - .5))*.7;
Y3 = (- (X.*.7 - .5).^7.*128 - 1)./15 - .1;
R3 = C3.*(X.*sin(P3) - Y3.*cos(P3));
H3 = C3.*(X.*cos(P3) + Y3.*sin(P3));
X3 = R3.*cos(T);
Y3 = R3.*sin(T);
% Colormap for sepals / 花托配色
CList2 = [178,173,113; 151,135, 73; 117,123, 50; 86, 89, 29; 75, 65, 17]./255;
CMat2 = zeros(100, 100, 3);
CMat2(:, :, 1) = repmat(interp1(linspace(0, 1, size(CList2, 1)), CList2(:, 1), linspace(0, 1, 100)), [100, 1]);
CMat2(:, :, 2) = repmat(interp1(linspace(0, 1, size(CList2, 1)), CList2(:, 2), linspace(0, 1, 100)), [100, 1]);
CMat2(:, :, 3) = repmat(interp1(linspace(0, 1, size(CList2, 1)), CList2(:, 3), linspace(0, 1, 100)), [100, 1]);
% Render sepals / 绘制花托
surf(X2, Y2, H2.*.8 + .12, 'CData',CMat2, 'EdgeAlpha',0.1, 'EdgeColor',CList2(end,:), 'FaceColor','interp')
surf(X3.*.93, Y3.*.92, H3.*.5 + .02, 'FaceColor',[ 84, 85, 54]./255, 'EdgeAlpha',0.1, 'EdgeColor','k')
[U2, V2, W2] = matRotate(X2, Y2, H2.*.8 + .12, Rx1);
[U3, V3, W3] = matRotate(X3.*.93, Y3.*.92, H3.*.5 + .02, Rx1);
surf(U2 + .7, V2 - .7, W2 - .6, 'CData',CMat2, 'EdgeAlpha',0.1, 'EdgeColor',CList2(end,:), 'FaceColor','interp')
surf(U3 + .7, V3 - .7, W3 - .6, 'FaceColor',[ 84, 85, 54]./255, 'EdgeAlpha',0.1, 'EdgeColor','k')
% A pulse function with two periods is applied
% to the contour to simulate the leaves.
% 让轮廓有2个周期且是脉冲函数,来模拟叶片
P4 = T.*0 + pi/16;
C4 = - abs(mod(T, pi)/pi - .5) + .11;
C4(C4 < 0) = 0; C4 = C4.*10; C4(51:100, :) = C4(51:100, :).*.7;
Y4 = (- (X.*1.01 - .5).^7.*128 - 1)./15 - .03;
R4 = C4.*(X.*sin(P4) - Y4.*cos(P4));
H4 = C4.*(X.*cos(P4) + Y4.*sin(P4));
X4 = R4.*cos(T);
Y4 = R4.*sin(T);
surf(X4 - .1, Y4 + .05, H4 - 2.2, 'FaceColor',[ 84, 85, 54]./255, 'EdgeAlpha',0.1, 'EdgeColor','k')
[U4, V4, W4] = matRotate(X4 - .1, Y4 - .1, H4 + .1, Rz1);
[U4, V4, W4] = matRotate(U4, V4, W4, Rx1);
surf(U4 + .7, V4 - .7 + 1, W4 - .6 - 1.2, 'FaceColor',[ 84, 85, 54]./255, 'EdgeAlpha',0.1, 'EdgeColor','k')
P5 = T.*0 + pi/8;
C5 = - abs(mod(T + pi/6, pi)/pi - .5) + .11;
C5(C5 < 0) = 0; C5 = C5.*5;
Y5 = (- (X.*1.01 - .5).^7.*128 - 1)./15 - .1;
R5 = C5.*(X.*sin(P5) - Y5.*cos(P5));
H5 = C5.*(X.*cos(P5) + Y5.*sin(P5));
X5 = R5.*cos(T);
Y5 = R5.*sin(T);
surf(X5, Y5, H5 - .3, 'FaceColor',[ 84, 85, 54]./255, 'EdgeAlpha',0.1, 'EdgeColor','k')
[U5, V5, W5] = matRotate(X5, Y5, H5+.1, Rx1);
surf(U5 + .7, V5 - .7 + 1/4, W5 - .6 - 1.7/4, 'FaceColor',[ 84, 85, 54]./255, 'EdgeAlpha',0.1, 'EdgeColor','k')
% Render stems / 绘制花杆
P1_1 = [mean(X3(:).*.93), mean(Y3(:).*.92), mean(H3(:).*.5 + .02)];
P1_2 = [mean(X5(:)), mean(Y5(:)), mean(H5(:) - .3)];
P1_3 = [mean(X4(:) - .1), mean(Y4(:) + .05), mean(H4(:) - 2.2)];
P1_3 = (P1_3 - P1_2).*1.4 + P1_2;
[XX1, YY1, ZZ1] = cylinderXYZ(P1_1, P1_2, .05);
[XX2, YY2, ZZ2] = cylinderXYZ(P1_2, P1_3, .04);
surf(XX1, YY1, ZZ1, 'FaceColor',[ 84, 85, 54]./255, 'EdgeAlpha',0.1, 'EdgeColor','k')
surf(XX2, YY2, ZZ2, 'FaceColor',[ 84, 85, 54]./255, 'EdgeAlpha',0.1, 'EdgeColor','k')
P1_1 = [mean(U3(:) + .7), mean(V3(:) - .7), mean(W3(:) - .6)];
P1_2 = [mean(U5(:) + .7), mean(V5(:) - .7 + 1/4), mean(W5(:) - .6 - 1.7/4)];
P1_3 = [mean(U4(:) + .7), mean(V4(:) - .7 + 1), mean(W4(:) - .6 - 1.2)];
P1_3 = (P1_3 - P1_2).*2.4 + P1_2;
[XX1, YY1, ZZ1] = cylinderXYZ(P1_1, P1_2, .05);
[XX2, YY2, ZZ2] = cylinderXYZ(P1_2, P1_3, .04);
surf(XX1, YY1, ZZ1, 'FaceColor',[ 84, 85, 54]./255, 'EdgeAlpha',0.1, 'EdgeColor','k')
surf(XX2, YY2, ZZ2, 'FaceColor',[ 84, 85, 54]./255, 'EdgeAlpha',0.1, 'EdgeColor','k')
% 在任意两点间构建圆柱
function [XX, YY, ZZ] = cylinderXYZ(P1, P2, r)
% CYLINDERXYZ Create a cylinder connecting two 3D points
% [XX, YY, ZZ] = cylinderXYZ(P1, P2, r) generates a cylinder
% of radius r between points P1 and P2.
v = P2 - P1; l = norm(v);
if l < eps, return; end
[XX, YY, ZZ] = cylinder(r, 30); ZZ = ZZ * l;
ddir = [0, 0, 1]; tdir = v / l;
if dot(ddir, tdir) > 0.9999
R = eye(3);
elseif dot(ddir, tdir) < -0.9999
R = [1, 0, 0; 0, -1, 0; 0, 0, -1];
else
av = cross(ddir, tdir); av = av / norm(av);
R = axisRotate(av, acos(dot(ddir, tdir)));
end
for ii = 1:size(XX, 1)
for jj = 1:size(XX, 2)
p = R * [XX(ii, jj); YY(ii, jj); ZZ(ii, jj)];
XX(ii, jj) = p(1) + P1(1);
YY(ii, jj) = p(2) + P1(2);
ZZ(ii, jj) = p(3) + P1(3);
end
end
end
% 通过矩阵旋转数据
function [U, V, W] = matRotate(X, Y, Z, R)
% MATROTATE Apply 3x3 rotation matrix to a set of 3D points
% [U,V,W] = matRotate(X,Y,Z,R) rotates points (X,Y,Z)
% using rotation matrix R.
U = X; V = Y; W = Z;
for ii = 1:numel(X)
v = [X(ii); Y(ii); Z(ii)];
n = R*v; U(ii) = n(1); V(ii) = n(2); W(ii) = n(3);
end
end
% 根据轴-角参数生成旋转矩阵
function R = axisRotate(axis, angle)
% AXISROTATE Compute rotation matrix from axis-angle representation
% R = axisRotate(axis, angle) returns a 3x3 rotation matrix
% for rotating by angle (radians) around the given axis vector.
% Implementation based on Rodrigues' rotation formula.
u = axis(1); v = axis(2); w = axis(3);
c = cos(angle); s = sin(angle);
R = [u^2 + (1-u^2)*c, u*v*(1-c) - w*s, u*w*(1-c) + v*s;
u*v*(1-c) + w*s, v^2 + (1-v^2)*c, v*w*(1-c) - u*s;
u*w*(1-c) - v*s, v*w*(1-c) + u*s, w^2 + (1-w^2)*c];
end
end
Charlie
Charlie
Ultima attività il 7 Maggio 2026 alle 20:52

It turns out you can very easily change the list of verbs Claude Code uses to display when it's thinking. I've had fun replacing them with some MathWorks-specific verbiage. Comment below if you have any ideas to add to the list!
You just add the following to your settings.json file:
"spinnerVerbs": {
"mode": "replace",
"verbs": [
"MATLABing",
"Simulinking",
"MathWorking",
"MathWorkin' on it",
"Pre-allocating arrays",
"Checking 1-based indexing",
"Vectorizing",
"Eigenvaluing",
"FFT-ing",
"Transposing",
]
  }
Jan Christian
Jan Christian
Ultima attività il 7 Maggio 2026 alle 15:53

I have been a loyal MATLAB user for 25 years, starting from my university days. While many of my peers migrated to Python, I stayed for the stability, compatibility, and clean environment. However, I am finding the 2025 version exceptionally laggy. Despite running it on an $10k high-end machine, simple tasks like viewing variables and plotting take up to 60 seconds - actions that were near instantaneous in the 2020 version. I want to stay continue with MATLAB, but this performance gap is a major hurdle and irritation. I hope these optimization issues can be addressed quickly.
One of the starter prompts is about rolling two six-sided dice and plot the results. As a hobby, I create my own board games. I was able to use the dice rolling prompt to show how a simple roll and move game would work. That was a great surprise!

Informazioni su Discussions

Discussions is a user-focused forum for the conversations that happen outside of any particular product or project.

Get to know your peers while sharing all the tricks you've learned, ideas you've had, or even your latest vacation photos. Discussions is where MATLAB users connect!

Altre aree comunitarie

MATLAB Answers

Poni e rispondi a domande su MATLAB e Simulink

Scambio di file

Scarica o contribuisci al codice inviato da un utente

Cody

Risolvi problemi, impara ad usare MATLAB e ottieni badge

Blog

Scopri MATLAB e Simulink dall’interno

Area giochi di chat AI

Utilizza l'intelligenza artificiale per generare la bozza iniziale del codice MATLAB e rispondere alle domande!