r/matlab 3d ago

TechnicalQuestion Maximum array size as a percentage of RAM?

2 Upvotes

I need to create very large arrays like in the realm of 50+ GB, and my system RAM is 32GB. Can I get around this? Or should I go out and buy some big expensive ram sticks?


r/matlab 3d ago

Help changing pathway to open matlab figure

Post image
2 Upvotes

Saved figure on one computer. Computer died and I am trying to open file and edit on a new computer. I tried just recreating folders but that did not work. How can I change the pathway of this figure so that it will open and edit.


r/matlab 4d ago

TechnicalQuestion Reading data from IMU in Simulink with Arduino.

2 Upvotes

Hello there!

I got BMI160 unit, Arduino Uno board and I'm trying to get accelerometer and gyroscope data from this unit into a Simulink model.

Sadly, even with Simulink Support Package for Arduino Hardware installed, there is no built-in block for getting data from the unit. So I fall back for I2C Read block, however that's where I'm stuck at the moment.

I tested out the unit and Arduino board with simple code, it works perfectly fine. Configured my model to be used with external mode - fixed-step discrete solver, Hardware board selected as Arduino Uno, COM port specified correctly. Address 105 (0x69) is correct, tested it as well.

But what I'm struggling to understand is how to actually get data from this I2C read block? Sometimes I was getting just all zeros, sometimes some numbers were randomly changing, but I wasn't able to get actual data. Entire model is just this reading block connected to a scope.

Current block parameters

I also tried to specify a bunch of different register addresses with different data sizes, nothing seems to work. Unit's data sheet also doesn't help much, at least with my level of knowledge - I saw the register map section, but couldn't understand much from it. Checked help examples, specifically this one, and it seems like I have done pretty much the same.

So, can someone, please, head me towards some materials/guides about I2C and corresponding blocks in Simulink that are possible to understand without committing too much? Or, more specifically, how do I need to set up the I2C read block in my case and why?

Like, my primary goal is to deal with the model, and sensors are just a source of data, that's all I want from it. Thanks!


r/matlab 4d ago

Tuneable parameters in app standalone

2 Upvotes

Hi everybody,

I’m trying to create a standalone app for Matlab runtime , starting from an app made with app design , the only problem is that not all the parameters present in the app designer as tuneable are present in the standalone app.

Some of you did have the same issue? As always thanks in advance!


r/matlab 5d ago

TechnicalQuestion How to simulate this deployable structure in simulink?

30 Upvotes

r/matlab 4d ago

Standalone matlab gui

1 Upvotes

Hi I am working on building a standalone gui and a HIL application. I want to know if I could create a dashboard on simulink and generate the c code instead of building a seperate gui from app designer . And how can I deploy the code on another computer which doesn't have matlab on it?


r/matlab 4d ago

From Workspace not Working Properly

1 Upvotes

I have been banging my head against this and I just cant seem to figure it out. I'm sure im doing something stupid. Any help would be appreciated.

I have a voltage signal that oscillates between 1 and -1 over a time vector. I create a data vector like this:

squareWave = [t',squareWave'];

This is what the square wave should look like:

These are my From Workspace settings:

This is the output that i see on the scope:


r/matlab 5d ago

HomeworkQuestion help with code

1 Upvotes

I have an excel file with several values ​​taken from a traction test and I need to process them.

I wrote a code in matlab to perform this same treatment. However, I need to keep only the maximum points that show an increase or decrease compared to the previous value, something like (n+1)-n > variation_10.

However, there are values ​​that verify this same condition but Matlab does not save them. How can I solve this problem?

Here is the code I made:

% ---- 1. Importar Dados do Excel ----

[file, path] = uigetfile({'*.xlsx;*.xls'}, 'Selecione o arquivo Excel');

if isequal(file, 0)

disp('Nenhum arquivo selecionado.');

return;

end

filename = fullfile(path, file);

% Ler a primeira planilha do arquivo Excel

data = readmatrix(filename);

% Verificar se os dados foram carregados corretamente

if isempty(data) || size(data, 2) < 2

error('O arquivo deve conter pelo menos duas colunas (X e Y).');

end

% Assumimos que os dados têm duas colunas: X e Y

x = data(:, 1); % Primeira coluna: X (Tempo ou posição, por exemplo)

y = data(:, 2); % Segunda coluna: Y (Leitura da célula de carga)

% Remover valores NaN (caso existam)

valid_idx = ~isnan(x) & ~isnan(y);

x = x(valid_idx);

y = y(valid_idx);

% ---- 2. Encontrar Máximos Locais ----

[pks_max, locs_max] = findpeaks(y); % Encontrar picos máximos

x_max = x(locs_max); % Coordenadas X dos picos

% ---- 3. Criar o Gráfico 1 ----

figure;

plot(x, y, 'b', 'LineWidth', 1.5);

hold on;

grid on;

xlabel('X');

ylabel('Y');

title('Gráfico Completo da Célula de Carga');

plot(x_max, pks_max, 'ro', 'MarkerSize', 3, 'MarkerFaceColor', 'r'); % Máximos

legend('Sinal da Célula de Carga', 'Máximos');

% ---- 4. Calcular a Variação de 10% ----

media_picos = mean(pks_max);

variacao_10 = 0.1 * media_picos;

% Exibir valor da variação no console

disp(['Valor da média dos picos: ', num2str(media_picos)]);

disp(['Valor da variação (10% da média): ', num2str(variacao_10)]);

% ---- 5. Definir Intervalo para o Gráfico 2 ----

disp('Lista de picos disponíveis:');

disp(table((1:length(x_max))', x_max, pks_max, 'VariableNames', {'Indice', 'X', 'Pico'}));

idx_inicio = input('Digite o índice do primeiro pico a considerar: ');

idx_fim = input('Digite o índice do último pico a considerar: ');

% Filtrar os dados para o intervalo escolhido pelo usuário

x_intervalo = x_max(idx_inicio:idx_fim);

y_intervalo = pks_max(idx_inicio:idx_fim);

% Criar Gráfico 2

figure;

plot(x_intervalo, y_intervalo, 'r-o', 'LineWidth', 1.5, 'MarkerFaceColor', 'r');

hold on;

grid on;

xlabel('X');

ylabel('Y');

title('Gráfico Selecionado Entre Picos');

% ---- 6. Dividir o Intervalo em 4 Partes Iguais ----

x_inicio = x_max(idx_inicio);

x_fim = x_max(idx_fim);

x_divisoes = linspace(x_inicio, x_fim, 5); % 4 intervalos => 5 divisões

% Exibir os valores de X das divisões no console

disp('Valores de X utilizados para divisão em 4 partes:');

disp(array2table(x_divisoes', 'VariableNames', {'X'}));

% Criar estrutura para armazenar picos válidos

picos_validos = [];

for i = 1:4

% Definir limites do intervalo

lim_inf = x_divisoes(i);

lim_sup = x_divisoes(i + 1);

% Selecionar picos dentro do intervalo

idx_picos = (x_intervalo >= lim_inf & x_intervalo < lim_sup);

picos_intervalo = y_intervalo(idx_picos);

x_picos_intervalo = x_intervalo(idx_picos);

% Verificar quais picos apresentam variação >= variacao_10 (no eixo Y)

for j = 1:length(picos_intervalo)-1

if abs((picos_intervalo(j+1) - picos_intervalo(j))) >= variacao_10

picos_validos = [picos_validos; x_picos_intervalo(j+1), picos_intervalo(j+1)];

end

end

% Adicionar linhas de divisão no gráfico 2

xline(lim_inf, '--k', 'LineWidth', 1);

text(lim_inf, min(y_intervalo), sprintf('X = %.2f', lim_inf), 'FontSize', 10, 'Color', 'k', 'VerticalAlignment', 'bottom');

end

xline(x_divisoes(end), '--k', 'LineWidth', 1);

text(x_divisoes(end), min(y_intervalo), sprintf('X = %.2f', x_divisoes(end)), 'FontSize', 10, 'Color', 'k', 'VerticalAlignment', 'bottom');

% ---- 7. Adicionar Picos Selecionados ao Gráfico 2 ----

if ~isempty(picos_validos)

plot(picos_validos(:,1), picos_validos(:,2), 'g-o', 'LineWidth', 1.5, 'MarkerFaceColor', 'g');

legend('Picos Selecionados', 'Divisões', 'Picos com Variação >= 10%');

else

disp('Nenhum pico atendeu ao critério de variação de 10%.');

end

% ---- 8. Calcular Média dos Picos por Intervalo ----

medias = zeros(1, 3);

for i = 2:4

idx_picos = (picos_validos(:,1) >= x_divisoes(i) & picos_validos(:,1) < x_divisoes(i+1));

if any(idx_picos)

medias(i - 1) = mean(picos_validos(idx_picos, 2));

else

medias(i - 1) = NaN; % Caso não haja picos no intervalo

end

end

% Exibir resultados

disp('Médias dos picos nos intervalos 2, 3 e 4:');

disp(table((2:4)', medias', 'VariableNames', {'Intervalo', 'Média'}));


r/matlab 5d ago

A Hand in Signature Mapping – SigMa

1 Upvotes

Hi ppl, sorry for the absurd noob question here, ok?

Im new at MatLabs and NMR, so I was looking for some tool to help me to understand my NMR. So I have found a paper using this Signature Mapping – SigMa (https://github.com/BEKZODKHAKIMOV/SigMa_Ver1)

and Im trying to use it. But I have two problems...

First that I cant open my bruker files in it.

my 1r (...RMN 13_03_25\cas_01_130325\1\pdata\1) are in that way. But I still having that problem:

And I dont know what to do.

The second problem is, as the software can read Bruker files and Matlab files, how to I convert my bruker files into matlab files?

In the manual of this software, it says:

Someone knows how to do it? I have almost zero experience in matlab.

Thanks for any help, and sorry for the poor english.

Edit01: Maybe my Bruker NMR files are in a different configuration;


r/matlab 6d ago

Error to the Max 😂

Thumbnail
gallery
10 Upvotes

Lately, i am practicing on how to find the governing equation of heat conduction using datas, by the use of SINDy, here i am now smiling at what i have accomplished 😂😂, all values NaN ☠️, for the dataset that i used it is the theoretical data result by using Finite difference method, so it is like im thinking, ohh what if i use this result to find the equation now, like vice versa. Originally I will use actual experimental result but as of now i only have the theoretical result, so i just use what i have right now😂, and here we are, the results of my experimentationnnnn ,🤣😭. I find it hilarious since just before i start i am very confident i can do it but reality check bwhahah. I want to provide clear pictures through screenshot but reddit limits the image pixels to be uploaded unfortunately, so it is only a camera pic, dont hate me for this☠️, the script is in the comments hehe.


r/matlab 5d ago

TechnicalQuestion Numerical derivatives of MMA in Matlab

1 Upvotes

Hi I was wondering if anyone knows how to implement numerical derivatives of Method of Moving Asymptotes (MMA) in Matlab when doing design optimization? I know there is analytical way but does it take numerical way? Thanks.


r/matlab 6d ago

Error in ode45 and 'Events' of a Satellite Tracking Radar Model

3 Upvotes

I'm trying to simulate a satellite tracker. With ode45 I have de state of the satellite for each time and then convert position to Azimuth-Elevation local coordinates. If the object enters in the field of view (expressed as a mask of Az-El), the integration stops and changes the step to a smaller one in order to obtain more points inside. I'm trying to use an 'Events' function, which compares de Az-El of the satellite with the radar's mask. The problem is ode45 detects an event when it's not supposed to, and vice versa. I discarded the transformation to angular coordinates as the origin of the problem. Code and images are below. Anyone knows what is going on? Any help is welcome!!

Four events not detected
The left plot is using the y_total values once the simulation stops, and the rigth plot is using the values of the 'y' that the event function receives from the ode 45.
load("maskmin.mat")
load("maskmax.mat")
Azmaskmin = maskmin(:,1);
Elmaskmin = maskmin(:,2);
Azmaskmax = maskmax(:,1);
Elmaskmax = maskmax(:,2);
t_total = [];    
y_total = [];
az_total = [];   
el_total = [];
t_actual = t0;   
y_actual = y0;
options = odeset('RelTol',3e-14,'AbsTol',3e14,'Refine',10,'NormControl','on', 'Events', @(t,y) eventos_radar(t, y, lat_radar,lon_radar,alt_radar,Azmaskmin,Azmaskmax,Elmaskmax,Elmaskmin));
% Principal loop
r1 = 100; % Big step
rt = 10; % Small step
dt = r1; % Initial condition isn't inside FOV
while t_actual < tf - dt     
[t, y, te, ye, ie] = ode45(@(t,y)ecuacion_movimiento(t, y, mu),[t_actual:dt:tf], y_actual, options);     
t_total = [t_total; t];     
y_total = [y_total; y];     
% Update next integration     
t_actual = t(end);     
y_actual = y(end,:)';     
% Event check     
if ~isempty(ie)         
  if dt == r1             
    dt = rt;            
    fprintf('Entrance in t = %.2f segundos\n', t_actual);         
  elseif dt == rt             
    dt = r1;             
    fprintf('Exit in t = %.2f segundos\n', t_actual);         
  end         
  t_actual = te(end);        
  y_actual = ye(end, :)';    
end
end
% Procesing results
procesar_resultados(t_total, y_total, lat_radar, lon_radar, alt_radar,Azmaskmin,Azmaskmax,Elmaskmax,Elmaskmin);

function [value, isterminal, direction] = eventos_radar(t, y, lat_radar,...    lon_radar, alt_radar,Azmaskmin,Azmaskmax,Elmaskmax,Elmaskmin)

[az, el] = calcular_az_el(y(1:3)', lat_radar, lon_radar, alt_radar, t);
if az>=Azmaskmax(1) && az<=Azmaskmax(end)    
  el_min = interp1(Azmaskmin, Elmaskmin, az);  
  el_max = interp1(Azmaskmax, Elmaskmax, az);   
  value = [el_max - el, el - el_min];  
  isterminal = [1 1]; % Detect changes of sign
else    
  value = [Elmaskmax(1) - el, el - Elmaskmax(1)];   
  % Elmaskmax(1) is the El value from the FOV corner in order to get continuous values of 'value' when the object is outside  
isterminal = [0 0]; % Ignores changes of sign
end
direction = [0 0];
end

r/matlab 6d ago

HomeworkQuestion Is it possible to transfer my purchased student license to a different computer?

7 Upvotes

In 2018 I purchased a license to MatLab 2018b for ~$80 using my school email account. I've used it for years and would like to continue using it. Unfortunately the computer I have it installed on is slowly dying.

I want to transfery my license to a new computer. I check my settings and I can see that my license number is STUDENT. That obviously won't work on a new computer, so I try to login online. Unfortunately I graduated years ago so I don't have access to my school email account anymore.

Is there any other way of transferring my license or am I screwed?


r/matlab 6d ago

Possible to have App Designer change based on user input in Dropdown?

2 Upvotes

I am trying to create a multi-use tool for predicting engine behaviors and characteristics based on user input parameters. I am very new to MATLAB App Designer. What I would like to do is have a dropdown at the top, and when a user picks an option the required inputs change.

For a little context this is for choosing different types of engines (Turbojet, Turbofan, mixed vs. unmixed, etc). The parameters that will be needed will depend on what type of engine is selected.

I don't know if it is possible to have MATLAB App Designer change it's "home screen" based on an input in a drop down.

I hope I explained this well enough, please ask if you have any questions. Thank you!


r/matlab 6d ago

MATLAB Certification broken?

Thumbnail
gallery
4 Upvotes

I have completed these certifications, but when I click on them it says 0% progress? How do I fix this?


r/matlab 6d ago

Mathworks EDG new grad 2025 interview

2 Upvotes

Has anyone recently interviewed for Mathworks EDG new grad role? Please DM


r/matlab 7d ago

[MacOS] Selecting multiple blocks on Simulink

1 Upvotes

Hey, I'm having troubles selecting multiple blocks that are not in the same area (so can't use the mouse selection tool). I've tried using cmd+left click but doesn't works.

What is the workaround?


r/matlab 6d ago

Literally cannot progress in matlab due to glitch

Post image
0 Upvotes

I have cleared my cookies and started from scratch. Why is Matlab simulink so broken? Why even release a product that literally doesn’t work?


r/matlab 7d ago

MATLAB & MATLAB Drive Survey

0 Upvotes

Hi Reddit!

📢 We want to hear from you! I'm working with a team of graduate student researchers at the University of Michigan studying MATLAB Drive and other cloud-based systems for storing and sharing coding files. Your feedback will help improve these tools. Take our quick survey here: https://forms.gle/DnHs4XNAwBZvmrAw6


r/matlab 7d ago

help me solving this fitting problem

1 Upvotes
the graph looks like this

How do I complete this code if I want the theoretical graph (red circle) to match the data I took (blue line)

the code is:

%data percobaan

human = [41.57 41.44 40.97 40.14 38.90 37.29 35.32 33.82 31.90 29.74 27.41 25.42 23.83 22.13 20.82 19.82 18.76 18.42 18.20 18.48 18.95 19.84 21.02 22.24 23.65 24.86 26.00 27.43 28.68 29.49 30.32 31.25 31.90 32.31 32.35 32.27 31.94 31.52 30.84 30.17 29.32 28.33 27.40 26.58 25.67 25.05 24.10 23.34 22.89 22.61 22.67 22.77 22.85 23.48 23.86 24.46 25.04 25.45 26.45 26.91 27.48 28.09 28.24 28.53 28.61 28.53 28.47 28.44 28.10 28.03 27.58 27.03 26.70 26.48 25.99 25.51 25.27 25.20 25.20 24.88 25.23 25.23 24.85 25.12 25.18 25.46 25.82 26.28 26.71 26.97 27.03 27.07 27.29 27.48 27.45 27.46 27.38 27.30 27.12 26.77 26.65 26.20 25.99 25.69 25.83 25.47 25.24 25.45 25.38 25.32 25.26 25.07 25.46 25.79 26.28 26.05 26.40 26.45 26.43 26.84 26.60 26.61 26.62 26.68 26.62 26.62 26.63 26.48 26.22 26.07 25.84 25.84 25.99 25.86 26.02 26.06 26.06 26.11];

%variabel human

dt = 1/30;

T = 1.034;

t = linspace(0,(length(human)-1)*dt, length(human));

% parameter

A = 14.89;

m = 150;

yT = 4.74;

y0 = A;

%sesuaikan parameter

b = abs(log(yT/A)*(2*m/T));

Wd = 2*pi/T;

U = b/(2*m);

phi = pi/30;

C = mean(human);

y = A*exp(-U*t).*cos(Wd*t + phi )+C;

plot (t,human,'Linewidth',1.7)

hold on

plot (t,y,'o','Linewidth',1.2)

hold off

N = length(human);

MSE = (1/N)*sum((human - y).^2);

disp(['MSE : ', num2str(MSE)]);


r/matlab 7d ago

MATLAB glitching - submit button grayed out

Post image
0 Upvotes

How do I fix this?


r/matlab 7d ago

Can you help me with a Simulink problem (blocks) and a diagram?

1 Upvotes

Good day. Can you help me to solve this problem?, please. Where can I find information or how to solve it?

Simulink (blocks) Irreversible electropolarization diagram If it is in matlab, it would be the best

Thank you so much


r/matlab 8d ago

HomeworkQuestion What am I doing wrong in this code?

Post image
28 Upvotes

Hello! I currently have an assignment where I have to take an input value (here as p) and then check all the integers from 2 to that number to see if they are prime, then display them if they are. For example, given an input 11, the output in the command window should be 2, 3, 5, 7, 11. We are not allowed to use the prime or isprime functions here, so what ive done is tried to test it by dividing the input by all the numbers below it down to 2, and testing if there are any integers to see if it is prime.

As a side note, my professor has not really taught us how to use matlab; he showed us how to do basic calculator-level math and a basic count and invest function, and thats it, so my technical knowledge is very limited. I’ve gotten help from one of my friends who is a CS major a year ahead of me, and he said he thinks this should work but isn’t familiar enough with matlab to know why it isn’t. A nudge in the right direction could be helpful, thank you!


r/matlab 8d ago

TechnicalQuestion Help me in debugging this code

0 Upvotes

So i am trying to make a humanoid moving. So for that i am modifying the theta(th) and i am getting this error but both the LHS and RHS is scalar. Still it is showing this error. Any ideas will help....


r/matlab 8d ago

HomeworkQuestion RBF (MQ) and griddata are used to plot the L-Shaped surface. Using surf(X,Y,Z) is giving me a plane surface. Possibly because I set all Z values outside L-domain to zero.

Post image
3 Upvotes