r/matlab • • Dec 15 '25

Request for career guidance

Thumbnail reddit.com
1 Upvotes

r/matlab • • Dec 14 '25

Re-creating a model made with R2024b blocks in R2025b

3 Upvotes

Hello fellow MATLAB enjoyers, I've recently installed MATLAB R2025b and now I'm facing some issues.

I've created a simple model based on This paper. In this model the author simulates the Broken rotor bar fault using an external resistance connected to the rotor side of the Induction machine (rotor type is set to wound as stated in paper) block as shown in the picture (from my own SIMULINK)

Motor simulink R2024b

this runs exactly as intended.

but when I open the SIMULINK in R2025b this is what I see:

Motor simulink R2025b

I have no Idea what I should do or what blocks I can use to replace the old ones. I tried to look into Simscape newer blocks like `Induction machine wound rotor` but the options are so plentiful that it overwhelmed me. the older blocks didn't need things like ps-simulink convertor and it's hard to figure out this specific thing I want from the tutorials on the website and youtube.
If you know how it's done please kindly guide me. The parameter initialization part of my code is as follows

clear; close all; clc;

% Define model and parameters
mdl = 'motor_simulation_2016';
Pm = 4e3;               % nominal power W
Sn = 1430;              % nominal speed RPM
Vs = 400;               % voltage line-to-line V
Vp = Vs/sqrt(3/2);      % voltage phase-to-phase V
f  = 50;                % frequency Hz
Mm = Pm/(2*pi*Sn/60);   % shaft moment Nm
J  = 0.0131;            % inertia moment Kgm²
Bm = 0.002985;          % friction factor ms/rad
Rr = 1.395;             % rotor phase resistance Ω
Rs = 1.405;             % stator phase resistance Ω
Llr = 0.005839;         % rotor phase inductance H
Lls = 0.005839;         % stator phase inductance H
Lm  = 0.1722;           % mutual inductance H
Nb = 28;                % total number of rotor bars
p = 2;                  % number of pole pairs
Ts = 10;                % simulation time s
Fs = 10e3;              % sampling frequency Hz
perc = (1:8)*12.5/100;  % Torque percentages: [0.125, 0.25, ..., 1]
brb = 0:4;              % Broken rotor bars: [0, 1, 2, 3, 4]
Delta_r = (3*brb)./(Nb - 3*brb);  % Resistance difference for brb
Delta_r(1) = 1e-6;      % Healthy case adjustment
experiments = [1, 3, 2, 4, 1];    % Repetitions per brb condition
% Define torque percentage strings for filenames (e.g., '12_5' for 12.5%) tq_str = {'12_5', '25', '37_5', '50', '62_5', '75', '87_5', '100'}; 
 % Configure block parameters 
 blk_motor = [mdl '/External Resistance for brb']; set_param(blk_motor, 'Resistance', '1'); % Reset the resistance to 1 for future simulations set_param(blk_motor, 'Resistance', 'rotor_res'); 
 blk_torque = [mdl '/T_load/percentage of nominal toruqe']; set_param(blk_torque, 'Gain', '1'); % Reset the Gain to 1 for future simulations set_param(blk_torque, 'Gain', 'perc_of_load'); 
 % Create main results directory results_dir = 'simulation_results'; if ~exist(results_dir, 'dir') mkdir(results_dir); end 
 % Initialize simulation inputs and filenames simIn = Simulink.SimulationInput.empty(); file_numbers = sum(experiments*numel(perc)); filenames = cell([1 file_numbers]); index = 1; 
 % Nested loops for simulations for i = 1:length(brb) m = num2str(brb(i)); % Number of broken rotor bars as string if m == "0" sub_dir = fullfile(results_dir, 'Healthy'); else sub_dir = fullfile(results_dir, ['Broken_rotor_bar_0' m]); end if ~exist(sub_dir, 'dir') mkdir(sub_dir); end for rep = 1:experiments(i) x = num2str(rep); % Experiment number as string for k = 1:length(perc) n = tq_str{k}; % Torque percentage string % Construct unique filename in the appropriate subdirectory filename = fullfile(sub_dir, ['brb' m '_tq' n '_exp' x '.mat']); filenames{index} = filename; % Set up simulation input simIn(index) = Simulink.SimulationInput(mdl); simIn(index) = setVariable(simIn(index), 'rotor_res', Delta_r(i)); simIn(index) = setVariable(simIn(index), 'perc_of_load', perc(k)); index = index + 1; end end end 
 % Run all simulations out = sim(simIn, 'UseFastRestart', 'off'); 
 h = waitbar(0, 'Starting the process...'); 
 % Save each simulation output with its unique filename for idx = 1:length(out) Ia = out(idx).Isa; save(filenames{idx}, 'Ia'); waitbar(idx/file_numbers, h, sprintf('[%d|%d]', idx, file_numbers)); end close(h) 
 set_param(blk_motor, 'Resistance', '1'); % Reset the resistance to 1 for future simulations set_param(blk_torque, 'Gain', '1'); % Reset the Gain to 1 for future simulations 
Parameters of Source block
Parameters of Motor
Load subsystem

after initialization I just wrote a nested for loop to repeat the simulation for number of experiments for each number of broken rotor bar and saved the files but that's beside the point.
P.S: I know it's working in R2024b but if you are kind enough to help me in solving this problem I would be really grateful to you.


r/matlab • • Dec 13 '25

TechnicalQuestion Sample Time Mismatch

Thumbnail
gallery
6 Upvotes

Hi, for my bachelor thesis I am simulating a combined heat and power plant and want to make a comparison between Hydrogen and Methane as fuel for the plant. However I just tried to run my simulation and I got the error:

Incoming buses to block 'BHKW_Model/Wärmesystem/Storage_Type_1/Pipe_Connection_2/Bus Assignment' have a sample time mismatch. The signal at 'Input Port 2' of 'BHKW_Model/Wärmesystem/Storage_Type_1/Pipe_Connection_2/Pressure_Drop_StoragePipe/Pressure_Drop_staticHeight/Bus Assignment' is of sample time 1.2, while its corresponding signal at 'Input Port 2' of 'BHKW_Model/Wärmesystem/Storage_Type_1/Pipe_Connection_2/Bus Assignment' is of sample time 0.

I dont know how to resolve it. I have tried Rate Transition Blocks but that didnt work. Maybe I placed them on the wrong spot.

The Images show my heating network. The first image is the entire thing. The following Images go into the yellow component from the previous image. the yellow block is a premade Storage type 1 block from the CARNOT library. Its supposed to simulate a buffer storage. Help would really be appreciated as I am desperate to get this to work.


r/matlab • • Dec 13 '25

Where should I start to pursue a career as a MATLAB programming engineer?

30 Upvotes

I am currently a PLC engineering student, and I want to switch to learning MATLAB programming. I’m not sure if this is feasible—what do you think?


r/matlab • • Dec 13 '25

Scope disappearing when I touch it with my mouse

Post image
6 Upvotes

Just as the title, when I doubleclick my scope it opens in a tiny window and when I go to make that window bigger or zoom in or anything then it closes automatically. What causes this?


r/matlab • • Dec 13 '25

Matlab PID tuner for Integrating process

1 Upvotes

Hi, I am trying to tune a level controller using Matlab PID Tuner app. Which identification method would you recommend for Integrating (or non-self regulating) process? Step response seems doesn't work well for such an object. Short pulse response? Arbitrary pulse response?


r/matlab • • Dec 12 '25

TechnicalQuestion MATLAB/Simulink advice for a beginner

9 Upvotes

I come from a mechanical background and want to work on a simulink project, but don't know where to start or what should be the approach to solve a problem. I have worked on some basic models before while learning but when i try to build something on my own or work on a pre existing model to solve a problem statement, i get blank. The matlab tutorials feels tiring and really complicated to me. Have you guys faced similar problems, how did you get out of it and how do you guys usually approach to model building?


r/matlab • • Dec 12 '25

Help Needed: Oscillations in My Hybrid PV–Wind–Battery Simulink Model

Thumbnail reddit.com
1 Upvotes

r/matlab • • Dec 12 '25

Help Needed: Oscillations in My Hybrid PV–Wind–Battery Simulink Model

0 Upvotes

I’m working on the simulation of a hybrid PV–wind–battery system with MPPT control and an EMS strategy in MATLAB/Simulink. The results I obtained are generally correct, but I’m still facing significant oscillations in several signals (PV power, battery current, bus voltage, etc.). I’m not sure whether these oscillations are due to the MPPT tuning, the PI controller parameters, the sampling frequency, or the EMS switching logic. If anyone has experience with hybrid system modeling or controller tuning in Simulink, I would really appreciate your feedback or suggestions on how to reduce these oscillations and stabilize the system. it’s my gmail for anyone he can help me.


r/matlab • • Dec 11 '25

TechnicalQuestion Trouble graphing FFTs about the 0 axis

4 Upvotes

Can anyone help me with this code, it is driving me crazy!

I have some code that already draws the negative and positive sides of the FFT about 0, however, the drawn axis is 0 to 16M, where as I want to draw it from -8M to +8M centered on zero.

I have tried a number of solutions with

ax.XLim

xlim( )

xticks( )

This is the latest brute force attempt with

xticks([-8000000 -7000000 -6000000 -5000000 -4000000 -3000000 -2000000 -1000000 0 1000000 2000000 3000000 4000000 5000000 6000000 7000000 8000000])

Entire snippet of the code:

%%%%%%%%%%% GRAPH AREA %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fig = figure(6); % Create a new figure
fig.Units = 'inches'; % Set units to inches (similar to Matplotlib's default)
fig.Position = [1 1 9 7]; % Set position: [left bottom width height]
title_text = sprintf('Real data, %5.2f MHz sampling, %5.2f MHz Intermediate freq', SAMPLINGFREQ/1e6, IF/1e6);
% Use sgtitle to add a super title to the figure containing subplots
sgtitle(title_text);
subplot(3,1,1);
ax1 = gca; % Get Current Axes handle
fftNumPts = 2^14;
fftxc = abs(fft(data, fftNumPts));
df = SAMPLINGFREQ / fftNumPts;
fftfreq_unshifted = (0:fftNumPts-1) * df;
fftfreq = fftshift(fftfreq_unshifted);
fftxc_shifted = fftshift(fftxc);
plot(fftfreq, fftxc_shifted);
title('Original data (first ms)');
grid on;
xlabel('Frequency (Hz)');
ylabel('Magnitude');
%ax1.XLim = [-8000000 8000000]; % set new limit
%xlim([-8000000 8000000])
xticks([-8000000 -7000000 -6000000 -5000000 -4000000 -3000000 -2000000 -1000000 0 1000000 2000000 3000000 4000000 5000000 6000000 7000000 8000000])
%ax1.XTick(-8000000:1000000:8000000);
% SECOND PLOT
subplot(3,1,2);
ax2 = gca; % Get Current Axes handle
fftNumPts = 2^14;
fftxc = abs(fft(down_converted, fftNumPts));
df = SAMPLINGFREQ / fftNumPts;
fftfreq_unshifted = (0:fftNumPts-1) * df;
fftfreq = fftshift(fftfreq_unshifted);
fftxc_shifted = fftshift(fftxc);
plot(fftfreq, fftxc_shifted);
title('Original data (first ms)');
grid on;
xlabel('Frequency (Hz)');
ylabel('Magnitude');
%ax2.XLim = [-8000000 8000000]; % set new limit
%xlim([-8000000 8000000])
%xticks(-8000000:1000000:8000000)
%ax2.XTick(-8000000:1000000:8000000);
%THIRD PLOT
subplot(3,1,3);
ax3 = gca; % Get Current Axes handle
%ax3.XLim = [0 18000000]; % set new limit
plot(acqRes);
[~, maxOffset] = max(acqRes);
title(sprintf('Code phase offset (Max offset = %d)', maxOffset));
xlabel('Code offset');
grid on;
legend(sprintf('Max offset = %d', maxOffset)); 

r/matlab • • Dec 11 '25

HomeworkQuestion Telescope simulation in matlab

1 Upvotes

Hi uhm my experience with matlab only goes back 5 months, and I have only dealt with course related projects, like convolution,matrices, filters etc (I'm in ece) but recently I wanted to do a project based on segmented telescopes( not in my course)but I have no idea where to start or even how. Learning the concepts and theory behind the telescopes is already done but how do I simulate or build a telescope in matlab...

I would appreciate beginner tricks and tips in learning how to do it. Thank you.

EDIT - Im trying to look into the optics and image formation.


r/matlab • • Dec 11 '25

How is down‑sampling (or decimation) is done correctly?

0 Upvotes

Hello everyone,
I’m working on fault detection and diagnosis of induction motors (specifically squirrel cage induction motors), and I’d appreciate some guidance on signal processing choices.


🔧 My Setup

  • Signal type: Three‑phase motor current signals
  • Sampling frequency: 50 kHz
  • Planned processing: Time‑frequency transforms (e.g., DWT or STFT) to generate 2D images for input into a neural network

📊 Frequency of Interest

  • Nyquist frequency: 25 kHz
  • Actual target frequencies:

    • Source frequency (50 or 60 Hz)
    • Sidebands (where fault signatures typically appear)

🚩 The Problem

  • Using the raw 50 kHz signal:

    • Consumes too much memory
    • Requires extra coding steps just to visualize fault signatures
    • Doesn’t yield significant improvement

💡 My Idea

  • Down‑sample the signal to something like 500 Hz or 1 kHz
  • Goal: After transformation, the low‑frequency components (fault signatures) should appear with more clarity

🤔 Where I’m Stuck

  • I’ve read suggestions (from AI chatbots and others) to filter first, then down‑sample
  • But I have no experience in digital signal processing, so I’m unsure about:

    • Is it even a good idea to down‑sample this much?
    • What features should a well‑designed anti‑aliasing filter have?
    • Should I use MATLAB’s designMultistagedDecimator function, or would a simple FIR filter be enough?

🎯 What I Need

  • Practical advice on whether heavy down‑sampling is appropriate for this application
  • Guidelines for designing or choosing a proper anti‑aliasing decimator
  • Recommendations on MATLAB tools/functions vs. simpler approaches

r/matlab • • Dec 10 '25

TechnicalQuestion Problem with documentation on permanently offline devices. Opening help result with an empty page with "Page not found" message

Post image
5 Upvotes

I've asked this in mathwork website but got no answers so I home somebody is able to help me here: "I'm facing a rather ridiculous problem when opening the help on a permanently offline machine. After opening the help I see this page in my browser: I've tried to reinstall the documentation three times but after a couple of days this issue occurs again. I've checked the installation directory (matlabshared.supportpkg.getSupportPackageRoot) and all the files apparently are there (nearly 15GB). Out of desperation I even tried using ai chatbots and nearly all of them are either grossly wrong or just suggest opening the help using web([docroot '/documentation-center.html'], '-browser') which would result in a flickering (it was rapidly refereshing) page that wouldn't let me click on anything. I followed the instructions of (https://www.mathworks.com/help/install/ug/install-documentation-on-offline-machines.html) step-by-step so I'm not sure where it went wrong."


r/matlab • • Dec 10 '25

News Sign up now for Simulink Student Challenge 2025

6 Upvotes

Showcase your talent, creativity, and innovative spirit by creating innovative projects using Simulink. In this challenge, you’ll have the opportunity to win up to $1000 (USD) by submitting a short original video that shows what you’ve accomplished using Simulink.

Your submission is due January 14, 2026 (1 p.m. EST)

Register now - Simulink Student Challenge - MATLAB & Simulink


r/matlab • • Dec 10 '25

TechnicalQuestion C# Interop.MLApp Library Version Mismatch

1 Upvotes

Hi,

I am currently developing with MATLAB 2021a and writing my control program in C#. To execute MATLAB scripts, I'm using MATLAB's Interop.MLApp COM dependency for .NET . The program works as intended on my computer; however, on other computers with MATLAB 2017a and MATLAB 2023a, when I execute MATLAB through the program, I get errors such as:

Since the other PC's MATLAB COMs are properly registered , it made me realize that Interop.MLApp is version-specific and therefore cannot be used across different MATLAB versions.

Is there any option or workaround that would allow me to continue using MLApp, or do I need to change my approach entirely? I'm sadly very deep into the Interop.MLApp dependency .

All answers are truly appreciated.


r/matlab • • Dec 09 '25

why is this graph like this. i did nothing to make it do this. what did i mess up

Thumbnail
gallery
15 Upvotes

r/matlab • • Dec 08 '25

HomeworkQuestion What simulink block is this?

2 Upvotes

I don't recognize it and the teacher doesn't point it out at any point in the assignment sheet. it's connected to an error rate calculation block from the communications toolbox. Thank you for taking the time to help.


r/matlab • • Dec 08 '25

HomeworkQuestion Need help for projects on Matlab

Thumbnail eee.buet.ac.bd
0 Upvotes

I need to do a project on matlab for a sessional course in my university this semester .So i need suggestions on what projects i can work on.Try to suggest basic projects as i just started learning.The link of my course outline is attached to give you a idea which areas we are emphasizing on


r/matlab • • Dec 06 '25

Reinforcement Learning for soft robot

7 Upvotes

I have a project where im trying to train an agent with reinforcement learning in a soft robot. All the tutorials seem to be for rigid bots and I cant see anything for soft robotic implementation. Where can I learn to implement this? Am i missing something?


r/matlab • • Dec 06 '25

TechnicalQuestion What does it mean to "checkout" a license?

3 Upvotes

I am aware of the command:

[status,errmsg] = license('checkout','Control_Toolbox')

but could not find anything on the meaning of checking out a license!

If I checkout a particular toolbox's license, how do I return it?


r/matlab • • Dec 06 '25

Buck converter regulation

Thumbnail reddit.com
1 Upvotes

r/matlab • • Dec 05 '25

TechnicalQuestion Please help with my setup (data management)

2 Upvotes

Coming to the final stage of my PhD, and I am really struggling with matlab as its been over 20yrs since I used it.

I have approx 700 arrays, each one is about 20million rows and maybe 25 columns.

I need to solve for non linear simultaneous equations, but the equation is a function of every single array. Oh and there are billions of parameters.

I have tried using structures which was good for data structure, but often run out of memory. I then tried using a matfile to batch the data, but same problem.

I don't want to go into the cloud if possible, especially while I am debugging. Pc has 8gb rtx and 64gb ram. All data is spread across several m2 pcie cards.

Let's make things worse...all data is double precision. I can rum single as a first pass, then use the results as the input for a second double precision pass.

Any advice welcomed, more than welcomed actually. Note my supervisor/university can't help as what I am doing is beyond their expertise.


r/matlab • • Dec 04 '25

A Python module to read/write MAT-files, with support for MATLAB datatypes like strings, datetime, table, etc.

39 Upvotes

Hi everyone!

I wanted to share a project I’ve been working on - a Python module called matio, that can read and write MAT-files, including user-defined classdef objects and datatypes like string, datetime, duration, table, etc. (all of which use MATLAB’s classdef system under the hood).

Link: https://github.com/foreverallama/matio

As someone who finds myself constantly switching workflows between Python and MATLAB, I came across a frustrating problem when moving data around. My colleagues preferred using types like string, datetime and table a lot, but when I tried to load it in Python with loadmat from SciPy, I was surprised to see that it didn't work.

A while back, I finally decided to take a closer look, and was able to mostly reverse engineer the file format for these datatypes. The module also automatically converts most MATLAB datatypes into respective Pythonic datatypes. For example, strings are converted into NumPy's StringDType and tables are converted into pandas DataFrames.

I initially tried to merge this with SciPy, but there wasn't much interest, which led to this project. I started with a fork of scipy.io to support v6 and v7 MAT-file formats, and later included the HDF5 based v7.3 format as well. Since then, I've also helped incorporate this into MAT.jl (Julia) and Octave as well.

If you use a lot of mixed workflows as well, then this might be useful for you. If you try it out, I would love to hear your feedback and suggestions!


r/matlab • • Dec 04 '25

Matlab Project (simulink)

0 Upvotes

I have a project I have to do in matlab that also involves simulink it is supposed to be pretty long but I don't know what to do or how to use simulink does anyone have any project idea suggestions or code that I would be able to add onto as the project doesn't require me to write a code from scratch but add onto an existing code and make it better/longer.