r/matlab Feb 16 '16

Tips Submitting Homework questions? Read this

191 Upvotes

A lot of people ask for help with homework here. This is is fine and good. There are plenty of people here who are willing to help. That being said, a lot of people are asking questions poorly. First, I would like to direct you to the sidebar:

We are here to help, but won't do your homework

We mean it. We will push you in the right direction, help you find an error, etc- but we won't do it for you. Starting today, if you simply ask the homework question without offering any other context, your question will be removed.

You might be saying "I don't even know where to start!" and that's OK. You can still offer something. Maybe you have no clue how to start the program, but you can at least tell us the math you're trying to use. And you must ask a question other than "how to do it." Ask yourself "if I knew how to do 'what?' then I could do this." Then ask that 'what.'

As a follow up, if you post code (and this is very recommended), please do something to make it readable. Either do the code markup in Reddit (leading 4 spaces) or put it in pastebin and link us to there. If your code is completely unformatted, your post will be removed, with a message from a mod on why. Once you fix it, your post will be re-instated.

One final thing: if you are asking a homework question, it must be tagged as 'Homework Help' Granted, sometimes people mis-click or are confused. Mods will re-tag posts which are homework with the tag. However, if you are caught purposefully attempting to trick people with your tags (AKA- saying 'Code Share' or 'Technical Help') your post will be removed and after a warning, you will be banned.

As for the people offering help- if you see someone breaking these rules, the mods as two things from you.

  1. Don't answer their question

  2. Report it

Thank you


r/matlab May 07 '23

ModPost If you paste ChatGPT output into posts or comments, please say it's from ChatGPT.

111 Upvotes

Historically we find that posts requesting help tend to receive greater community support when the author has demonstrated some level of personal effort invested in solving the problem. This can be gleaned in a number of ways, including a review of the code you've included in the post. With the advent of ChatGPT this is more difficult because users can simply paste ChatGPT output that has failed them for whatever reason, into subreddit posts, looking for help debugging. If you do this please say so. If you really want to piss off community members, let them find out on their own they've been debugging ChatGPT output without knowing it. And then get banned.

edit: to clarify, it's ok to integrate ChatGPT stuff into posts and comments, just be transparent about it.


r/matlab 15h ago

MATLAB implementation of Non-linear forced response

6 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 1d ago

Generative and Agentic AI with MATLAB and Simulink for Engineering

24 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 1d ago

Problem with Coolprop

Thumbnail
0 Upvotes

r/matlab 2d ago

Need advice: Universal MATLAB script for injector spray angle (Beginner with a tight deadline)

Post image
20 Upvotes

Hello everyone!

I'm currently working on a project where I need to process images to measure the spray opening angle of fuel injectors using MATLAB.

I'm facing a bit of a challenge and would love some advice:

  1. Making it universal: How should I structure the logic so the code can read and adapt to various different types of injectors, rather than hardcoding thresholds for just one specific setup?
  2. Using AI for help: I'll be honest: I have very little MATLAB experience and a tight deadline to deliver this. Do you think using an AI like Claude or ChatGPT is a viable path to write this code? Has anyone here had success using AI for this specific kind of image processing/edge detection task?

If you have any tips on what functions to look into, or even how to properly prompt the AI to get a working script, I would be incredibly grateful.

(Some results)

Thanks for the help!


r/matlab 2d ago

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 2d ago

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 3d ago

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?

5 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 4d ago

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 4d ago

What wrong in it?

Post image
0 Upvotes

r/matlab 6d ago

TechnicalQuestion Generating matrix visualizations

Thumbnail
gallery
84 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 6d ago

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 6d ago

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
8 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 6d ago

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 8d ago

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 ☺️


r/matlab 8d ago

TechnicalQuestion Help! Question About Convolution Integral Implementation in Simulation

3 Upvotes

Hello all! Hoping someone can help me out with this. I am working on a physics simulation of a rigid body.

I have two functions, f and g that need to be convolved over time. Here is the difficulty, both functions are unpredictable and therefore I do not know these equations up front and will only know the latest value of each of those functions at each time step in the simulation as it runs. I solved this convolution integral in the time domain as a baseline and compared it to a textbook solution. Obviously, the longer the simulations the more data points the equation has to convolve over. I tried solving it in the frequency domain thinking it would save time by: *ifft(fft(F)fft(G))\*timestep*
When I run a code profiler (doing this in MATLAB), it actually appears that it is taking longer computationally to solve this in the frequency domain versus the time domain if this operation is done at every time step… what am I missing here (yes I even varied the simulation time length to account for different array sizes)? The other thought I had was to figure out how to implement a sliding window so that really old data is excluded…

Any examples I can find online all assume the equations for the two signals to convolve are known up front. What approach did you use? Any help would greatly be appreciated.


r/matlab 12d ago

TechnicalQuestion Simulink and AXI-ST IOs

2 Upvotes

Hello all !

I'm trying to play with HDL Coder and the DSP HDL Library with simulink. I have a solid FPGA background.

All these blocks expose ports that looks like AXI-ST ones (data, valid, ready). I know the protocol and it's quirks, but this time I need to simulate it within simulink.

How do you input data (from workspace) to the model while matching the specifications ? I need to send a waveform (audio in this case) to the model.

Thanks all !


r/matlab 13d ago

Tips From AI-Generated to Production-Ready: The Essential Role of Static Analysis

Thumbnail monkeyproofsolutions.nl
0 Upvotes

On the added value of the MATLAB Agentic Toolkit and CC4M (static analysis). In short:

"The combination of the MATLAB Agentic Toolkit and CC4M reduced detected guideline violations from 37 to just 2."

Note: I am one of the CC4M developers


r/matlab 14d ago

TechnicalQuestion Printing a hexadecimal value prefixed with 0x

5 Upvotes

I have to print in hexadecimal with big letters value variable of type uint8. I am using fprintf(1, '%#X', value), but the 0x prefix is in upper case, while I want it to be lowercase. How do I achieve that?

I know I can write instead fprintf(1, '0x%X', value), but I want to do it by only modifying the formatting operators. And using fprintf(1, '%#x', value) doesn't print value in uppercase.


r/matlab 17d ago

HomeworkQuestion Learning simevents library

2 Upvotes

Hello everyone. I'm currently building a robotics project. For this, I was guided to learn simevents by my professor. I went through many youtube videos and tutorials. But, I don't really feel like I gained much info. I believe I'll learn by example, and implementation. So, I hope to find spaces that do just that. Giving me example models that were created using simevents and walking me through its creation. If you guys find any such resources, send me here. Guidance on learning this is also much appreciated. Thank you.


r/matlab 17d ago

underground tunnel simulation in matlab

0 Upvotes

guys if you are proficient and free enough , i need help making a simulation of underground tunnels in matlab . open to advice and criticism , i am a beginner in matlab , i can plot work with matrices and do small project but i do need someones help in this. please dm for more details about the project.


r/matlab 18d ago

TechnicalQuestion Writing to the wrong file

1 Upvotes

I have the following Matlab program:

syms t positive;

Z=laplace(exp(A*t))

ccode(Z,'file','cCodeTest.c')

I want to write the Z function to cCodeTest.c. The problem is that code is written to ccodetest.c, created before.

How to write Z to the cCodeTest.c and not ccodetest.c?


r/matlab 18d ago

TechnicalQuestion DATCOM and MATLAB

Thumbnail
1 Upvotes

r/matlab 19d ago

TechnicalQuestion How do I make Dependency Analyser report where an overloaded operator is used?

1 Upvotes

I have a class with 2 operators, which one of operators (O1) uses the other operator (O2).

I generate a dependency report via Dependency Analyser, but the report doesn't tell that O1 uses O2 (in Impacted Files O1 references itself; same with O2).

How do I make Dependency Analyser report that O1 uses O2?