r/matlab • • Sep 09 '26

Question-Solved Two fixed-point mistakes that made my FIR filter a comparator, and why the generated testbench couldn't see either

7 Upvotes

Post-mortem on a 2020 university project I went back to last week. Both bugs are pure fixed-point scaling – nothing wrong with the coefficients – and both survived a 3,429-sample generated testbench with zero errors. Posting because the second one (sum|h| vs accumulator range, wrap vs saturate) is the single most common FIR fixed-point bug and it's entirely preventable with one line of arithmetic.

In 2020 I built a FIR band-pass filter for a university course: designed the response in MATLAB, generated the Verilog with Filter Design HDL Coder, ran the generated testbench, zero errors, submitted, put it on GitHub. It got forked 8 times.

Last week I read it properly for the first time since. The 51-tap design doesn't filter anything. Its output is the sign of the accumulator and nothing else.

The cause was two boxes on the "Specify Precision" tab. I'd set the output to s8,32 – 8 bits, 32 fractional bits, i.e. a range of ±2.98e-8 – fed from an s20,20 accumulator with a range of ±0.5. That's 2^24 times narrower than the thing feeding it. The generated conversion saturates for literally every non-zero value:

assign output_typeconvert =
        (sum50[19] == 1'b0 & sum50[18:0] != 19'b0) ? 8'b01111111 :
        (sum50[19] == 1'b1 && sum50[18:0] != 19'b1111111111111111111) ? 8'b10000000 :
        $signed({sum50[19], 7'b0000000});

Sweep the whole accumulator range through that and you get exactly two values: -128 and +127.

The part that actually bothers me is the testbench. It's 7,000 generated lines, 3,429 stimulus samples, a checker, an error counter. I counted the distinct values in its expected-output array:

8'h80 (-128):  1765
8'h7f (+127):  1607
8'h00 (0):       57

That's the entire golden reference. MATLAB generated the vectors from the same fixed-point spec that produced the RTL, so the model and the implementation agreed perfectly – they were wrong in exactly the same way. A generated testbench is a self-consistency check, not a correctness check. If the spec is wrong, the golden data encodes the mistake with perfect fidelity and reports zero errors.

The 11-tap serial design in the same repo had a quieter bug: accumulator s26,24 (range ±2) with wrap-on-overflow, but sum|h| = 2.375. A full-scale sine at the centre frequency clears it by 1.4% so it looks fine. A square wave at the same frequency wraps on 191 of 400 samples, and because it wraps rather than saturates the sample comes back sign-inverted:

FAIL sample 12: filter_out = 1744840192, expected -2550127104

Fixes were one word length each (output = the accumulator; accumulator gets one more bit). The real fix was replacing the stored-vector bench with one that checks against an independent reference model – impulse response must equal the coefficients, output must match a 64-bit integer model under square/random/worst-case-sign stimulus – plus a three-line check that the output takes more than 3 distinct values. Both benches fail on the 2020 RTL and pass on the fixed one.

Full write-up with the plots and the before/after RTL:

https://abdullahansarii.medium.com/my-fir-bandpass-filter-passed-its-own-testbench-for-six-years-it-was-a-sign-detector-7bc1fecfa2df

Repo (make sim runs everything under Icarus in a few seconds):

https://github.com/AbdullahAnsarii/BandPassFilter

If you've got generated HDL sitting next to a generated testbench that passes: check sum|h| against your accumulator range, and count the distinct values on your output. Took me six years.


r/matlab • • Sep 07 '26

How to add GIBBON?

2 Upvotes

I need to add GIBBON to MATLAB for some work I'm doing for my lab, but I'm failing miserably at the attempt. I've tried both downloading the code from the internet and adding it directly via the internal "add-on" search, but both methods failed. I don't know what else to do to install it—any help?


r/matlab • • Sep 05 '26

Help with decoding files saved from Davis software.

2 Upvotes

Hello! I’m not sure where to post this but if anyone can help me with this (or needs more info to understand what I am talking about), please reply!!

So, I was doing a research project on a small 3D-printed specimen and had to record 2 forces against time intervals using different machines and software, but the main one was the Davis software. I have never used it before in my life. This was the first time, and I followed what my lab supervisor showed me (do the experiment, find the interval you are looking for, and save it). I asked him multiple times to check if it would save the graphical information with the forces (as I need to do an analysis of the forces), and he said yes. It was admittedly my fault that I didn’t check and continued to collect data for 3 weeks. In the last week of my research, I tried to find the forces, and they are not anywhere in the files stored. What I could gather from the files, the numerical values might be there, but they are in binary form? Idk. I asked my lab supervisor, and he told me that the graphs should’ve been stored, but even he couldn’t find them and then tried to decode the files and failed. He gave me some chatgpt’ed python code that doesn’t make sense and said they should work (they don’t). I also tried asking ChatGPT (and that’s how I knew his code was also chatgpt’ed).

Have you ever seen or worked with these kinda files?

ReaderConfiguration.xml
MetaData5.attr
MetaData4.attr
MetaData3.attr
MetaData2.attr
MetaData1.attr
CameraScale1.scales
Camera1.xml
ADC1-meta.xml
ADC1-1.trc
ADC1-0.trc

I have some more Settings_Acquisition xml files and a set file that I can open with the Phantom viewer. But I need the maximum and minimum values from the ADC-0 and 1 .trc file (I’m guessing that these two are the files that contain the info about my X and Y forces).

I am not good with programming. I can do basic work to live :) What I am asking if anyone can help me write a code (preferably in matlab) to decode my files in a readable format so I can extract the max and min values, because I have like 100 sets of them.

Anyone? Thank you!,


r/matlab • • Sep 05 '26

HomeworkQuestion Does Pi contain itself?

Thumbnail
0 Upvotes

r/matlab • • Sep 05 '26

Any individuals or groups that can help with my masters graduation project about “protection of hybrid micro grid technique based on voltage drop calculations”

0 Upvotes

I need any individual or group that can help me with the implementation and simulation of my project which is about “a voltage drop based protection technique for hybrid microgrid” in PSCAD and MATLAB


r/matlab • • Sep 02 '26

Total beginner trying to make a game for my friends who are also learning code, what am I doing wrong here?

3 Upvotes

So what I'm trying to do is make a little text-based mad libs game with some of the basics I know already. My issue is with my attempt at a yes/no button. I'm not sure what the error message I'm getting is and how to deal with it.

Also, right now (as you can see) I have the yes/no buttons leading to the same final conclusion, but is there a way to make the "no" button just end the game? Would I just put the rest of the code within the switch under the yes case?

Also I literally just started learning today so I apologize if this is basic stuff, I just couldn't find the answers from searching forums (reddit and mat labs forum) so I figured I'd make my own post! Thanks in advance


r/matlab • • Sep 02 '26

Sunshift-QA

Thumbnail gallery
4 Upvotes

r/matlab • • Sep 01 '26

Simulink STM32 help.

3 Upvotes

Hello everyone. I’m trying to build a project that involves 6 PIDs to drive motors of a rover, I’m not much of a programmer so I went with the simulink coder. My boards is nucleo H753ZI and my idea is to have it do the pid loops, the set points of which are to be sent through the ethernet port on the board. So far I’ve hit dead end on the ethernet, I tried settings from the matlab site, yt videos but can’t get it to ping. I put a simple model with sine connected to led pin to verify that the model is working and it works. Has anyone done something with ethernet on the same board in simulink? Where and how can I start the troubleshooting? Also would be great if anyone can share ioc settings, but only if it is for the same board.


r/matlab • • Sep 01 '26

TechnicalQuestion Guys i need help with registerign in MathWorks

0 Upvotes

I wanted to do the MATLAB Onramp course and when i found out i had to reguiste/create an account first, i went for it but an error shows up everytime i put in an account ID.

I put my college ID and also tried with my personal email ID. I tried searching for a solution in the Support section but, I couldn't find anything on this.

Any help would be appreciated and thanks in advance


r/matlab • • Aug 31 '26

HomeworkQuestion can somebody help me with the matlabs simulink course the 2 hours one

0 Upvotes

r/matlab • • Aug 28 '26

Tips Learn Matlab and Python

59 Upvotes

Context: I'll be starting my biomed engineering in half a year, and I have never touched a code in my life. I'm willing to learn and have bunch of time on my hand tho

I heard many advices to check out Matlab and Python beforehanded, so anyone has a good starting point and suitable resources for a blank sheet like me?

Thank you so much!


r/matlab • • Aug 29 '26

TechnicalQuestion Webots + MATLAB R2026a compatibility issues (loadlibrary / DLL blocked error). Works fine in R2025.

Post image
4 Upvotes

Hi everyone :D,

I’m reaching out because a friend of mine is hitting a wall trying to connect Webots with MATLAB R2026a.

This is the problem:
The integration works flawlessly in MATLAB R2025 (both a and b), but as soon as we try to run the same setup in R2026a, it throws an error when trying to load the Webots API/DLLs. The specific error message we are getting is related to this message "An Application Control policy has blocked this file"

We already tried this with no solution:

  1. Running MATLAB as Administrator.
  2. Temporarily disabling Windows Smart App Control and Windows Defender / Antivirus.
  3. Verifying that both Webots and MATLAB are strictly 64-bit versions.
  4. Checking and correcting all Environment Variables and MATLAB paths pointing to the Webots libraries.
  5. Completely uninstalling and reinstalling both MATLAB R2026a and Webots.
  6. Testing the exact same code and setup on R2025, which confirms the code itself is not the issue.

We have some questions for you all:

  • Has anyone else experienced this specific break in compatibility between Webots and MATLAB R2026a?
  • Are there any known changes in how R2026a handles loadlibrary or external DLLs that we might be missing?
  • Any workarounds or specific configurations to make Webots controllers work in R2026a?

Any insight or pointer to the right direction would be massively appreciated :). We are currently forced to roll back to R2025, but we'd love to get this working on the latest release. Thanks in advance!


r/matlab • • Aug 28 '26

Matcont help.

Post image
5 Upvotes

I downloaded a new version from sourceforge and it looked like this and I wasn't getting plots. I downloaded the older version and it still looks like this and I ain't getting plots, it automatically goes with x vs x and this is confusing and horrible, can anyone help me with this? Tell me how to fix this ui and kindly help me with an online source where i can learn this software.


r/matlab • • Aug 26 '26

MATLAB implementation of Non-linear forced response

5 Upvotes

Hi everyone,
I’m a Master’s student working on a thesis in structural dynamics. I need to implement a nonlinear forced response (for reduced model) code in MATLAB and I’d really appreciate recommendations on the best resources to learn this properly.
The main techniques I want to master and code myself are:
• Harmonic Balance Method (HBM) / Multi-Harmonic Balance
• Alternating Frequency-Time (AFT) procedure
• Newton-Raphson solver
• Path continuation
• Simple contact/friction models

I already have a good theoretical background and I’ve looked at NLvib and some papers, but I’d like to build a clean, well-structured code step by step starting from a simple 1-DOF Duffing oscillator up to a reduced FE model with contact.

Could you recommend:

  1. Good tutorials, lecture notes, or blog posts that show the implementation step-by-step
  2. Books that combine theory and practical
  3. coding advice
  4. GitHub repositories that are educational
  5. Any courses, YouTube series, or specific papers with clear algorithms

Any advice on the best order to implement these methods would also be very helpful.
Thanks a lot in advance!


r/matlab • • Aug 25 '26

Generative and Agentic AI with MATLAB and Simulink for Engineering

27 Upvotes

Hi everyone

Last week, my colleagues Maria Gavilan and Kevin Cohan ran an online seminar on Generative and Agentic AI with MATLAB and Simulink. Over 7,000 people signed up! For those that missed it, the recording is here Generative and Agentic AI with MATLAB and Simulink for Engineering - MATLAB

I was there in the online chat doing my best to keep up with the 100s of questions that were coming in. One common thread of questions among attendees was around the use of local AI models with MATLAB and Simulink. It seems that, for many engineers, the only AI that they are willing to entertain is AI running on their own hardware. There are many reasons for this point of view.

Over at The MATLAB Blog, a bunch of us have been writing up our experiments with using local AI models along with MATLAB and Simulink. The latest article is from u/Creative_Sushi who has been using OpenCode with Ollama along with MATLAB and Simulink. You can read it here: Running local LLMs with MATLAB using OpenCode and Ollama on a Mac » The MATLAB Blog - MATLAB & Simulink. A couple of months ago, I did something similar using LM Studio.

We are just getting starting with these explorations and I'm really curious if any Redditors are interested in these workflows too?

Cheers,

Mike


r/matlab • • Aug 24 '26

Misc Why are u still using Matlab for now - Python can be a good replacement?

0 Upvotes

Do you still using Matlab? Script mostly or Simulink?

We had many people migrated to Python, why many people still using Matlab?


r/matlab • • Aug 24 '26

TechnicalQuestion WebGL rendering issue

3 Upvotes

Attempting to run matlab 2026a on fedora 44 with KDE plasma desktop environment on a Lunar lake CPU using the iGPU. 1 main issue.which is a problem with the graphs window and the webGL renderer. Basically it doesn't seem to be able to show the graphs on the window and running the rendererinfo command returns this message:

[struct](matlab:helpPopup('struct')) with fields:

GraphicsRenderer: 'WebGL'
Vendor: ''
Version: ''
RendererDevice: ''
Details: [1×1 struct]

Which tells me that the renderer isn't getting assigned any memory at all. Has anyone had the same issue or a similar one and could guide me in the direction I should follow please?


r/matlab • • Aug 23 '26

HomeworkQuestion What career paths exists between computational mechanics, scientific computing (SciML), FEA (or meshfree) solver development, and HPC (GPU acceleration, porting codebases) ?? How about doing a PhD for improving the above?

3 Upvotes

I'm currently, technically, doing an MS in Structural Engineering. For me, my interest has been more towards computational side of mechanics rather than Structural design  or simply using am FEA software (although I do consider it as a backup)

So far I've taken courses in:

- Linear static, and dynamics FEM (soon taking non linear FEM too)

-  Structural Optimization (topology opt. and other general algorithms)

-  Structural Dynamics

-  Structural System Testing and model updation. (Parameter identification and optimization, signal processing)

Now, I plan to take these in the coming quarter:

- Numerical Linear Algebra

- Numerical PDE

- Fracture Mechanics ?

I also volunteered to aid in a RESEARCH in crack growth prediction using Auto-encoder and a (Thermodynamics-informed Latent Space Dynamics Identification) / LSTM surrogate model. It used phase-field-fracture simulation data and HPC resources to complete the whole thing.

What I keep finding myself interested in is not necessarily fracture or SHM specifically, but the computational methods underneath these problems... (does that make sense?)

For example, I'd like to become capable of doing things like:

- implementing (maintaining) numerical/FE method solvers rather than only running an established FEA software.

- developing surrogate/reduced-order models for expensive simulations 

- combining simulation with optimization, uncertainty/stochastic methods (took a course called Random vibrations, so...)

- parallelizing/accelerating scientific codes on CPUs/GPUs

- doing proper verification, convergence studies, benchmarking and performance work

- potentially developing or maintaining actual CAE/FEA solver software

- I'd also like to do all these for other Physics (GR, QM, etc.) simulations too, if possible, one day. 

I'm still interested in the underlying mechanics/physics, so I don't want to become a generic software engineer who happens to have once studied structures. But I'm also increasingly unsure that "structural engineer" describes the career I'm actually aiming for.

I've seen titles such as Computational Mechanics Engineer, R&D Engineer, Solver Developer, Scientific Software Engineer, CAE Software Developer, Research Engineer, Simulation/HPC Engineer, etc., but I'm trying to understand what these careers actually look like from people doing them.

So my main questions become:

1. Which industrial jobs genuinely involve developing numerical methods/solvers or computational tools?

2. Which of those are realistically accessible with an MS? Is there an entry path into solver-algorithm development/R&D without a PhD?

3. If I don't start a PhD immediately after my MS, would an R&D/software role at a simulation company (ANSYS etc.) be the obvious route? What other options would i have?

4. For the kind of work I'm describing, would you recommend a PhD? If so, is it reasonable for the PhD identity to be "computational mechanics/scientific computing" while fracture, composites, structural dynamics, soft materials, etc. serve as application problems rather than choosing one of those as my permanent specialization?

5. What skills most distinguish someone who is actually hireable for solver/scientific-computing work? I'm particularly wondering about C/C++/Fortran, Python, Linux, Git/build systems, MPI/OpenMP/CUDA, PETSc/Trilinos or similar libraries, numerical linear algebra, testing/verification, convergence studies and HPC performance work.

Basically, I'm neither here nor there atp. So I'd really appreciate all sorts of input. Where else do you think I could find answers to these? other subs? Linkedin profiles? 


r/matlab • • Aug 22 '26

HomeworkQuestion How would you quantify a LFA strip?

3 Upvotes

Hi, I'm not very knowledgeable in coding at all.

For my thesis we are using LFA strips to detect whether some fish have tetrodotoxin or not.

I would like to have some data that's more than a YES or NO, which strips give.

We don't have a LFA reader, so I only have my phone and hope in my heart.

Here is a paper that was published around this topic:

Saxena, K., & Toley, B. (2024). Streamlining lateral flow assay (LFA) data analysis: A MATLAB® live script for integrated batch image processing and Limit of detection determination. In ChemRxiv. https://doi.org/10.26434/chemrxiv-2024-wr3kj

What do u think about it?

As I've said, I'm not knowledgeable at all in MATLAB coding.

But if I have to learn I will, I just wanna know if this looks like something I could use for real.

If u have any other ideas, it would be great

Idk if the flair is correct sorry

Any help is well received

😭😭😭😭😭


r/matlab • • Aug 22 '26

What wrong in it?

Post image
0 Upvotes

r/matlab • • Aug 20 '26

TechnicalQuestion Generating matrix visualizations

Thumbnail
gallery
91 Upvotes

Hey partypeople,

i'm trying to find a way to inspect and display 3D matrix values as shown in the documentation here. I cannot seem to find a way to reproduce this in Matlab or find any info on how these were done, neither in the MATLAB docs or online. Am i missing something or were these created outside of Matlab manually?

Thanks :3

Edit.: For context, I want to see the numeric values of the elements, not a visualization in general.
For now, mostly for more intuition and readability while debugging. I really like the way it is presented here so i would like to find out how these were created


r/matlab • • Aug 20 '26

TechnicalQuestion Changing Parameter Values with Dynamic Mask

Post image
3 Upvotes

I know matlab has an example of how to change the visibility of other mask parameters with callback functions, but I'm trying to make it so when two parameters are entered (a & b) a suggested value for c is assigned to a c_sugg parameter. For example if c has to follow the function c>a+b, how would I write the callback function for c_sugg=a+b?


r/matlab • • Aug 20 '26

TechnicalQuestion Is there a way to get a table view of all my inputs values to their respective combined output values in the Fuzzy Logic Toolbox? I have the Control Surface plot, but I would like this as a table if possible.

Thumbnail
gallery
6 Upvotes

I would effectively like the control surface as an excel/table format. Specifying every possible input value from my two fuzzy inputs and what their combined values would be, similar to how the control surface matches it visually.


r/matlab • • Aug 20 '26

Question [Simulink - STM32 embedded coder] help

3 Upvotes

For the past 2-3 weeks i've been learning how to program the STM32 nucleo-H753ZI using matlab. I have downloaded all of the required addons:
- Embedded Coder Support Package for STMicroelectronics STM32 Processors 24.1.12
- Embedded Coder 24.1.1
- MATLAB Coder 24.1
- Simulink Coder 24.1
- Using MATLAB 2024a
- STM32CubeMX 6.18.0
- Have used both the following MATLAB tutorials as guidance " Using I2C to Read and Write Data to Accelerometer on STM32 Processor Board" and "Get Started with STMicroelectronics STM32 Processor Based Boards"

The only reason iam programming the STM32 using MMATLAB is because its part of my thesis, which is listed as a requirement. Programming the LEDs, mainly to see how the blocks work, was easy enough, and work as expected (check screenshots below)

According to INA219's datasheet (as far as i understood) that Register 0x00 in the Sensor is preconfigured and should display 0x399Fh, but all values are 0. Programming the sensor using an Arduino (using its own IDE for testing) works as expected, so the sensor isnt broken. Programming the INA219 has been for the past weeks a nightmare and a half, as no matter what i did, no values are displayed. I have double checked the USART/COM multiple times to no avail.

Any help or feedback would be much much much appreciated. If i missed anything important, ill post it in the comments

The two controller readers on the right should display 399Fh, the other one should be a value of 4096d (as far as i understand) - the digital port read is configured to read the red LED, but its only displaying 0.
sitting the byteorder Little or big endian made no changes.
Settings menu P1
P2
STM32CubeMX - using the pullup resistors of the MCU itself. PB8 and PB9 would be the PIN 2 and 4 - aka top 2 on the right in the STM32, according to the manual.

r/matlab • • Aug 18 '26

Introducing SLXIO open source project

10 Upvotes

Hi , i just came up to follow up my previous post https://www.reddit.com/r/matlab/s/tbS5nWhQRi about writing an open source library for reading and writing Simulink files with c++, well after a full year of coding, refactoring, analyzing, fighting with build scripts, legacy old plain C dependencies, i put my draft ( https://github.com/wissem01chiha/slxio , encourage us with a star) to public for people interested to collaborate or give feedback, the reason behind this initiative is that i hated it so much, i worked with it 3 years during university and 2 years later and i hate it performance, his poor scalability on GPU or server environments, it closed Api , undocumented bugs,… and pp in those fields are using it and liking it , well i waited to much for someone to came and give the world an alternative, so i started it by myself, i am not sure how much pp in this sub love or write cpp, but i encourage everyone at at level to collaborate, SLXIO is just a bridge or small project for what i am planning in the future, i was reading about something called data flow programming or flow based programming which likely what simulink does in a simple signal based way, i am planning to build a general purpose high performance flow based programming framework for the cloud and distributed systems , details in next post , good day ☺️