{"id":4136,"date":"2026-02-09T08:47:45","date_gmt":"2026-02-09T13:47:45","guid":{"rendered":"https:\/\/blogs.mathworks.com\/matlab\/?p=4136"},"modified":"2026-02-10T17:31:43","modified_gmt":"2026-02-10T22:31:43","slug":"coding-a-matlab-valentine-animation-with-agentic-ai","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/matlab\/2026\/02\/09\/coding-a-matlab-valentine-animation-with-agentic-ai\/","title":{"rendered":"Coding a MATLAB Valentine animation with agentic AI"},"content":{"rendered":"<div class = rtcContent><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><a href = \"https:\/\/blogs.mathworks.com\/matlab\/2025\/02\/13\/on-love-and-research-software-sharing-code-with-your-valentine\/\"><span>Last year's Valentine post <\/span><\/a><span>was an attempt to link a few Valentine's MATLAB animations with good practice in research software engineering. This year, I used Claude Code along with <\/span><a href = \"https:\/\/blogs.mathworks.com\/matlab\/2025\/11\/03\/exploring-the-matlab-model-context-protocol-mcp-core-server-with-claude-desktop\/\"><span>MATLAB's MCP server<\/span><\/a><span> to develop this animation that morphs between the MATLAB membrane and a 3D heart<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><img class = \"imageNode\" src = \"http:\/\/blogs.mathworks.com\/matlab\/files\/2026\/02\/claudeValentine_1.gif\" width = \"670\" height = \"296\" alt = \"\" style = \"vertical-align: baseline; width: 670px; height: 296px;\"><\/img><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>I am quite pleased with the result and it was another excuse to practice more with agentic coding tools in a low stakes situation. I used used some of the agentic AI development ideas discussed in the recent post <\/span><a href = \"https:\/\/blogs.mathworks.com\/matlab\/2026\/01\/26\/matlab-agentic-ai-the-workflow-that-actually-works\/\"><span>MATLAB + Agentic AI: The Workflow That Actually Works<\/span><\/a><span>.<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Writing code like this was quite an interesting experience for me since it felt completely different to how I usually work. It definitely felt like a iterative collaboration between Claude and me. Initial versions did not look good at all! Once we had it looking the way I wanted it to, performance stank. I got around this by sending the results of the MATLAB profiler to Claude Code and figuring out together what to do about it.<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>The little floating hearts were Claude's idea. Once we had the basic animation working, I entered Claude Code's planning mode and asked it for ideas of embellishments. It suggested and implemented several, of which the floating hearts was my favorite so that's the one I kept. <\/span><\/div><h2  style = 'margin: 20px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: 700; text-align: left; '><span>Try using AI yourself to produce a Valentine animation in MATLAB <\/span><\/h2><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Usually, I'd share the code with you along with an <\/span><a href = \"https:\/\/uk.mathworks.com\/products\/matlab-online\/git.html\"><span>'Open in MATLAB Online'<\/span><\/a><span> link and encourage you to play with it yourself. This time, however, the workflow that I'd like to encourage to you to use is <\/span><a href = \"https:\/\/blogs.mathworks.com\/matlab\/2025\/11\/03\/exploring-the-matlab-model-context-protocol-mcp-core-server-with-claude-desktop\/\"><span>MATLAB's MCP server<\/span><\/a><span>. This allows you to connect your AI of choice to your desktop MATLAB. Essentially, it allows your AI to drive MATLAB directly on your machine. Use this to produce your own Valentine MATLAB code, either attempting to reproduce mine or coming up with something else entirely. <\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>If you don't feel quite ready to use agentic AI, you can try some of our other AI tools such as<\/span><a href = \"https:\/\/uk.mathworks.com\/products\/matlab-copilot.html\"><span> MATLAB Copilot<\/span><\/a><span>, <\/span><a href = \"https:\/\/uk.mathworks.com\/matlabcentral\/playground\/new\"><span>The MATLAB AI Chat Playground<\/span><\/a><span> or <\/span><a href = \"https:\/\/chatgpt.com\/g\/g-QFTjbeK3U-matlab\"><span>MATLAB GPT<\/span><\/a><span>.<\/span><\/div><h2  style = 'margin: 20px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: 700; text-align: left; '><span>Where to post the results of your work<\/span><\/h2><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Once you have got some working code that you are happy with, try uploading it to GitHub and optionally add an <\/span><a href = \"https:\/\/uk.mathworks.com\/products\/matlab-online\/git.html\"><span>Open In MATLAB Online button<\/span><\/a><span> to your README.md file. This will make it as easy as possible for other people to run your code, even if they don't have a MATLAB license. <\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Next, tell the world about it. Post the link to the repo and any screenshots or animations to the <\/span><a href = \"https:\/\/uk.mathworks.com\/matlabcentral\/discussions\/ai.html\"><span>MATLAB Central Generative AI discussion forum<\/span><\/a><span>.<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>When we tried a similar exercise on <\/span><a href = \"https:\/\/uk.mathworks.com\/matlabcentral\/discussions\/ai\/885765-let-s-vibe-code-christmas-trees\"><span>Vibe-coded Christmas trees<\/span><\/a><span>, we posted the code directly to a single discussion thread and quickly brought the forum software to its knees. Lesson learned; hence the workflow suggested above.  <\/span><\/div><h2  style = 'margin: 20px 10px 5px 4px; padding: 0px; line-height: 25px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: 700; text-align: left; '><span> <\/span><span style=' font-weight: bold;'>A quick note on Agentic AI safety:<\/span><\/h2><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>If you choose to go the agentic route, remember that agentic tools are powerful! A few simple habits go a long way toward using them safely, securely, and responsibly:<\/span><\/div><ul  style = 'margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-size: 14px; '><li  style = 'margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap; '><span style=' font-weight: bold;'>Scope access narrowly<\/span><span> - allow the coding agent to see only the specific project folder it needs.<\/span><\/li><li  style = 'margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap; '><span style=' font-weight: bold;'>Use Git for traceability<\/span><span> - version control gives you transparency, history, and easy rollback.<\/span><\/li><li  style = 'margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap; '><span style=' font-weight: bold;'>Review everything<\/span><span> - generated code, terminal commands, file operations, and any external links.<\/span><\/li><li  style = 'margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap; '><span style=' font-weight: bold;'>Approve only actions you understand<\/span><span> - avoid letting the agent execute steps you are not familiar with.<\/span><\/li><li  style = 'margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap; '><span style=' font-weight: bold;'>Protect sensitive data<\/span><span> - do not use confidential or regulated data, content or code with coding agents.<\/span><\/li><li  style = 'margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap; '><span style=' font-weight: bold;'>Use trusted components<\/span><span> - stick to MCP servers, Claude Skills, and plugins from reliable sources.<\/span><\/li><\/ul><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span> <\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><\/div>\r\n<\/div><script type=\"text\/javascript\">var css = ''; var head = document.head || document.getElementsByTagName('head')[0], style = document.createElement('style'); head.appendChild(style); style.type = 'text\/css'; if (style.styleSheet){ style.styleSheet.cssText = css; } else { style.appendChild(document.createTextNode(css)); }<\/script>","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/matlab\/files\/2026\/02\/claudeValentine_1.gif\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div><p>Last year's Valentine post was an attempt to link a few Valentine's MATLAB animations with good practice in research software engineering. This year, I used Claude Code along with MATLAB's MCP server... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/matlab\/2026\/02\/09\/coding-a-matlab-valentine-animation-with-agentic-ai\/\">read more >><\/a><\/p>","protected":false},"author":176,"featured_media":4134,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[78,63,128,60,135],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/posts\/4136"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/users\/176"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/comments?post=4136"}],"version-history":[{"count":2,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/posts\/4136\/revisions"}],"predecessor-version":[{"id":4138,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/posts\/4136\/revisions\/4138"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/media\/4134"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/media?parent=4136"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/categories?post=4136"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/tags?post=4136"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}