r/matlab

I implemented the Runge–Kutta (RK4) method in C++ to solve a second-order differential equation
▲ 1 r/matlab+1 crossposts

I implemented the Runge–Kutta (RK4) method in C++ to solve a second-order differential equation

Hi everyone,

I recently implemented the Runge–Kutta Fourth Order (RK4) method in C++ to solve the second-order differential equation

ax¨+bx˙+cx=0

The tutorial covers:

  • Converting a second-order ODE into two first-order equations
  • Implementing the RK4 algorithm in C++
  • Writing simulation data to a .dat file
  • Plotting Position vs Time and Velocity vs Time using GNU Plot

The goal was to make the implementation easy to understand for beginners and engineering students learning numerical methods.

I'd really appreciate any feedback on the implementation, coding style, or explanation. Suggestions for future C++ or numerical methods tutorials are always welcome.

If you find the tutorial helpful, please consider liking the video, sharing it with others who might benefit, and subscribing to the channel. Your support helps me create more tutorials on C++, Numerical Methods, Engineering Simulations, and GNU Plot.

Thank you for your support! 🚀

youtu.be
u/Nucleus_1911 — 11 hours ago
▲ 129 r/matlab+4 crossposts

I reorganized my control and robotics course materials into a free GitHub repository

I recently made a major update to my Control and Robotics learning repository and decided to keep the course materials freely accessible.

The repository now includes structured course folders with standalone HTML lecture pages, mathematical explanations, diagrams, and companion code examples for many lessons. The topics cover areas such as:

  • Linear control
  • Modern control
  • System dynamics
  • Robot kinematics and dynamics
  • Robot control
  • Advanced robotics
  • Autonomous mobile robots

For some lessons, the code examples are provided in different languages/environments such as Python, C++, Java, MATLAB, and Wolfram/Mathematica, so the material can be studied from both the theory and implementation side.

Repo: https://github.com/mohammadijoo/Control_Robotics_Lab

I’m sharing it here in case it is useful for students, instructors, or self-learners working through control systems and robotics topics. I would also appreciate feedback, especially if you notice mistakes in equations, explanations, code examples, structure, or missing topics that would make the material more useful.

u/abolfazl1363 — 1 day ago
▲ 15 r/matlab

MATLAB on Arch-Linux

If you've tried running modern MATLAB (R2024a/R2026a+) on Arch Linux

or CachyOS under Wayland, you know it's a nightmare. It usually

silently crashes before the UI renders, the activation window spawns

invisibly, or the `MathWorksServiceHost` dies instantly with

"communication errors."

I spent a lot of time debugging the crash logs and tracing the

library collisions, and I've put together a GitHub repo with an

automated bash script that fixes all of it in one go.

**What the script fixes:**

  1. **The Wayland GUI Crash:** MATLAB bundles ancient versions of

`freetype`, `glib`, and `fontconfig` that crash instantly on modern

Linux. The script isolates them so MATLAB uses your system libraries.

  1. **The `lc_init` Crash (CachyOS specific):** If you use CachyOS or

`libleancrypto`, it collides with MATLAB's licensing libraries and

instantly kills `MathWorksServiceHost`. The script automatically

downloads the official Arch versions of `nettle` and `gnutls` and drops

them directly into the ServiceHost folder, perfectly bypassing the

crash.

  1. **The Invisible Activation Bug:** Outlines how to launch the

Product Authorizer with `QT_QPA_PLATFORM=xcb` so you can actually click

"Activate".

Just run `./fix_matlab_arch.sh` and it handles the library surgical

strikes for you. Hopefully, this saves someone the headache I went

through!

github.com
u/AggravatingTale3872 — 1 day ago
▲ 6 r/matlab

Matlab for macbook not compatible?

Hi, I was told that matlab won't work well on a MacBook. I have a MacBook Air M2, 8 GB, macos 15.3.1. If this is true what alternatives do i have? I have to use psychtoolbox preferably. And I’m about to start my term so any help would be useful.

reddit.com
u/Fit_Coat_1938 — 3 days ago
▲ 1 r/matlab

Specific Parameter Definition Question

I'm trying to design a masked subsystem to use as a buck power converter and I'm trying to make it as user friendly as possible.

For my model, I have a subsystem with no inputs or outputs that serves as a "settings" block where users can fill out edit blocks and hit click functions to change the configuration of the model. While I have edit blocks to change parameters of my masked subsystems, particularly for the Buck converter, I want to make it so once the Vin, Vout, and switching frequency is entered, suggested minimum inductance and capacitances are displayed in the settings block. Is there a way to save and display the suggested minimum L and C's as values are being entered.

reddit.com
u/cakemaster1928 — 4 days ago
▲ 5 r/matlab

computational biology

high schooler here; need some help using mat lab for a research project

any tutorials that someone can recommend to learn how to create plots from using bio gps data? my whole goal is to be able to predict the outcome of a certain type of cell differentiating into 3 other types. looking for the data sets to import has been hard, because nothing really on the internet is in-your-face like "here is a data set of everytime a MSC has differentiated into a bone cell"

i could just use some help. also im using 30-day free matlab rn so im kinda struggling

reddit.com
u/PositiveLettuce3502 — 5 days ago
▲ 13 r/matlab

Aerospace engineering student from Morocco looking for advice

I'm a 21-year-old aerospace engineering student from Morocco, and I know I want to work in flight dynamics and control. That's the area of aerospace that genuinely interests me the most.

My concern is that there seem to be very few jobs in Morocco related to flight dynamics, flight control, guidance, or autopilot systems. Most aerospace jobs here are in manufacturing, quality, maintenance, or production.

I'm currently studying flight dynamics and control systems, reading Flight Dynamics Principles by MV Cook, learning MATLAB, and working on a longitudinal dynamics/pitch-hold autopilot project.

For those of you working in flight controls or similar fields:

- If you were in my position, how would you prepare over the next 2 3 years?

- What skills made the biggest difference when getting your first job?

- Which projects actually impressed employers?

- Besides MATLAB Simulink, what should I be learning?

- How realistic is it to build a career in flight dynamics and control if you have to start from a country with almost no opportunities in that field?

I'd appreciate honest advice from people who've been through it. I'm trying to build the strongest foundation possible and avoid wasting time on things that won't matter.

reddit.com
u/Ornery_Artichoke5130 — 5 days ago
▲ 8 r/matlab

Is learning MATLAB+Simulink worth it as a Physics Graduate in the UK

Hi, I have just graduated with a BSc in Astronomy and Physics from the University of Glasgow and am looking at ways i can maximise my employability within different sectors, and was generally wondering how worth it learning MATLAB would be to improve my employability within an engineering role. I understand that engineering is an incredibly broad industry though, and looking it up the only current information i can seem to get is from google AI telling me that its worth it with no valid source.

reddit.com
u/Drew--1987 — 5 days ago
▲ 43 r/matlab

Is that statistic R or R squared

I haved it confusing, i have read papers were it is referred to as R squared, graphically I see R? help out

u/geeky22 — 7 days ago
▲ 3 r/matlab

Support requested for MATLAB errors during GeneWeaver dataset processing

Hello everyone,

I am reaching out to ask for some technical support regarding an issue I am encountering in MATLAB.

I am currently working with some datasets downloaded from GeneWeaver to derive the gold standard matrix (specifically, the ground-truth network for our in silico simulations).

As shown in the attached screenshot, the current script performs the following steps:

  • Automatically loads the source data.
  • Transforms the gene interactions into adjacency matrices.
  • Saves the output into the target folder (named '10').

However, during execution, MATLAB returns two types of errors that I have been unable to resolve. Has anyone encountered similar issues, or could you point me in the right direction to fix this?

Thank you in advance for your time and help.

https://preview.redd.it/eh0ffz3l68ah1.png?width=670&format=png&auto=webp&s=8bbd06c95d5b40a60977a1132634c639a1917bac

https://preview.redd.it/hby2v30e68ah1.png?width=501&format=png&auto=webp&s=a548bd18d9ff4c59e127771674ded2612151160f

https://preview.redd.it/z46uudyq58ah1.png?width=1327&format=png&auto=webp&s=c994cfe225dbbf96cccda1b1885c4ab19df19c4b

reddit.com
u/kappaellegi — 7 days ago
▲ 34 r/matlab

how should i learn matlab for aerospace engineering/mechanical engineering.

currently i have completed my 12th and also learning python from yt. i want to ASK THAT from which platform should i attend lectures for this .

reddit.com
u/Acrobatic-Media-3597 — 11 days ago
▲ 10 r/matlab+3 crossposts

HELP REGARDING PROJECTS RELATED TO AEROSPACE INDUSTRIES

Hello everyone, I will shortly be beginning my 3rd year of electrical engineering. I have taken the signal and systems course but DSP will be one of the subjects in the upcoming sems.

Though i have keen interest in aerospace industries and wanted do some projects. I was following the book by INGLEY AND PROAKIS to learn DSP along with MATLAB. I have completed till the basic design techniques of the FIR, IIR filters.

The problem i am stuck on was that i can't think of any relevant DSP projects as per my interests. Anything related to avionics is mostly radar stuff. I tried skimming through that stuff but i realised i had to take some radar related courses to get hold of it and make something.

And most other ideas i find are related to image processing, audio processing etc. A week ago i was tired of this shit and finally decided to make something.

I began the project of writing a jpeg decoder and today as i am close to completing it, i realised i learnt nothing of actually the things i wanted to learn😭😭. Man i don't know what to do.

I have previously read and introductory book on kalman filters by Alex becker and made an attitude estimation kalman filter with help of quaternions. Though it isn't worth direct application to a vechile i still consider it a good unique relevant project.

I want to make another such project like that but i can't get any good ideas. If you have any suggestions please help me in comments.

reddit.com
u/Right-Advisor2978 — 11 days ago
▲ 7 r/matlab

Can't use matlab online.

I am new to using MATLAB and the issue is when I try to turn on matlab online I get stuck at this loading page. It doesn't go beyond this. Please help 🙏 😭

u/Legitimate-Total3384 — 10 days ago
▲ 9 r/matlab

Getting your model to match your data

We've seen a few posts here along the lines of "my Simulink model doesn't match my data" or "I modelled X but can't get the experiments to agree"... And similarly from students, "how do I find the parameters of my motor/ battery/ bioreactor?"

Aycan Hacioglu and I wrote a blog about this, using a bioreactor brewing beer as the example. But the same idea can be applied to any system of interest, alongside relevant experimental data.

This is what we are discussing: 1) build a model that captures the overall behaviour, 2) run a sensitivity analysis to identify which parameters actually drive your outputs (not all of them do), 3) then use Simulink Design Optimisation to tune the important ones against your experimental data.

If you want to read more about it, here's the blog: https://blogs.mathworks.com/engineering/2026/06/18/on-parameter-estimation-sensitivity-analysis-and-design-optimization/

https://preview.redd.it/i0ocbyp8zu8h1.png?width=974&format=png&auto=webp&s=4e7fa81353d11c504497f7f3cc53b0bda1bbd021

reddit.com
u/Barnowl93 — 13 days ago
▲ 27 r/matlab

“Agents are just LLM + loop + tools.” - demystifying AI agent with MATLAB

I know AI is a polarizing topic - people are both fascinated and at the same time feel intimidated.

To me, the best way to deal with it is to understand how it works, and that's why I created the most minimal implementation of it in MATLAB, and it is now out on GitHub.

It runs locally:

- No API key
- No token cost
- Everything stays local

This is just a toy project, but it works pretty well, IMHO.

Start exploring the code by inspecting agent.m. Open get_system_prompt.m to see the system prompt, and check the tools folder to take a look at how tools are defined. None of them is big, and they are easy to read.

Fork it, play with it, make changes and make it your own.

https://github.com/toshiakit/minimal-matlab-agent (also available in File Exchange and in Add-on Explorer)

u/Creative_Sushi — 14 days ago
▲ 2 r/matlab

Does interp1 function query at the exact point you input?

I have a position & velocity time-series, and I want to find the velocity at all points when position crosses zero. To make sure I get every crossing, I've been linearly approximating the correct time (with the point-slope formula).

Then, I've been fitting a spline through 5 neighboring points and using the interp1 function to solve for velocity at these points:

vel_star = interp1(t(window), vel(window), t_star, 'spline');

Is there any deciding matlab does with this function? As in, are we really solving for velocity when t is exactly equal to t_star? Or would it be better to fit a function to the nearby points?

I'm not familiar with this function, so any help would be really appreciated!

reddit.com
u/Lively_Raccoon — 13 days ago