94,677 questions
1
vote
0
answers
112
views
High-dimensional function inputs in MATLAB Experiment Manager
The specific Experiment Manager of interest is here https://www.mathworks.com/help/matlab/ref/experimentmanager-app.html. Other related documentation is specifically for AI, but I am interested in ...
0
votes
0
answers
70
views
Need help narrowing down range of interest to the tangent between an arc and rectangular block [closed]
Current Crack Detection
Hello, I need help narrowing down the range of interest to the tangent between the arc and rectangular block. It's able to highlight a small portion of the crack I want it to. ...
4
votes
1
answer
229
views
The same code runs on MATLAB but in R it is unstable
I am using spectral method to solve an ordinary differential equation.
The following R code and the MATLAB code are completely the same.
But the R code gets explode (the u value it solved would become ...
1
vote
0
answers
48
views
MATLAB Documentation for SPM1d
I am trying to use the two-sample ttest in the spm1d MATLAB package. I have watched the tutorial videos on Youtube and know how to run tests similar to what's shown in those videos. I am wondering if ...
Advice
1
vote
3
replies
72
views
Why the statement '[a] = size(x)' does not assign the product of dimensions of 'x'?
The command help size shows that:
[M1,M2,M3,...,MN] = size(X) for N>1 returns the sizes of the first N
dimensions of the array X. If the number of output arguments N does
not equal NDIMS(...
1
vote
1
answer
73
views
Simulink 2023b PV Model Outputs NaN Even With Constant Inputs — What Am I Missing?
I'm using MATLAB/Simulink 2023b and built a very simple PV model: constant irradiance (1000), a PV array block, and measurement blocks. But when I run the simulation, all outputs show NaN, even though ...
4
votes
1
answer
75
views
Display order for overlayed datasets in histogram
Let's say we have 3 datasets of the same size, that we want to plot on the same histogram:
Dataset_1 = [1 1 1 1 1 1 2 2 2 2 3 3];
Dataset_2 = [1 1 1 2 2 2 2 2 2 3 3 3];
Dataset_3 = [1 1 2 2 2 2 3 3 3 ...
Advice
1
vote
5
replies
99
views
How to show values from one matrix while coloring using another matrix with MATLAB heatmap?
This is the code from my current heatmap:
N = 36;
Lat_extended = [Latency; zeros(N*N - length(Latency), 1)];
Lat_matrix = reshape(Lat_extended, N, N);
figure;
heatmap(Lat_matrix)
And the figure,
The ...
1
vote
0
answers
56
views
Bad colormap interpolation when not using the default colormap
My code doesn't work well when I apply a custom colormap. It does well with the default colormaps; however, when I specify my own it doesn't work.
My current code is this:
mymap = [
0.769, 0.992, 1....
1
vote
0
answers
53
views
Extracting free spaces from a occupancy grid map in the MATLAB
How can I extract free spaces from a occupancy grid map in the MATLAB. I have the following code which gave the output that there is no free cell on the occupancy grid map.
clc;
clear;
close all;
rng(...
1
vote
0
answers
33
views
Configuration structure error with Fieldtrip in Matlab
I'm running into an error while attempting to setup a configuration structure for a single subjects EEG data using Fieldtrip. While I think the answer is plain, I am unable to figure out for the life ...
1
vote
0
answers
42
views
Want to get rid of "jagged teeth" from DTS simulator made in matlab
So I made a program in matlab that numerically simulates a DTS system and its almost right but there's one detail that there's "jagged teeth" in the graphic diagram ( circled in blue ) ...
-2
votes
0
answers
34
views
How to change size of marker in rltool matlab
I want to make my poles and zeros markers bigger. In PLOT I had this option in properties, but in rltool I don't have the same option. I've tried to use set(0, 'DefaultLineMarkerSize', 8); but this is ...
1
vote
0
answers
61
views
Reassigning a Matlab pointer in a loop without a memory leak
We are using Matlab to communicate with a C++ library, and are struggling with memory management.
We create a libpointer pointing to an array, and then try to update its value in a loop. I don't think ...
1
vote
0
answers
21
views
Grey Wolf Optimizer (GWO) MPPT in MATLAB/Simulink returns only lower bound value as reference speed
I am implementing a Grey Wolf Optimizer (GWO) for Maximum Power Point Tracking (MPPT) to generate the reference speed in a wind energy conversion system using Simulink.
However, when I run the ...
0
votes
0
answers
40
views
Ray tracing for the offner stretcher
Please help me refine the ray tracing code of the Stretcher Offner in MATLAB.
I used the formulas from the article to plot graphs from Figure 3, showing the dependence of the group delay on the ...
3
votes
0
answers
104
views
How can I plot diagonals of matrix?
I want to plot all the diagonals of a matrix. In the matrix row 1 contains information of time 1, row 2 of time 2 etc etc. Each diagonal presents the evolution of the number of fishes in a cohort that ...
-1
votes
1
answer
60
views
Matlab script to write to Excel file, have excel calculate, and read output in a for loop
I am trying to build a Matlab script to write data to an Excel file, have the excel file execute, and pull out another cell as the output. I asked an AI engine to give me a script and it came up with ...
4
votes
2
answers
97
views
What is wrong with my implementation of logic in this MATLAB code?
I am stuck on a problem with my MATLAB code. This should behave as a pathing program for a calculation. However, it seems to not follow the logic I instructed it. The logic is that, at the current ...
1
vote
0
answers
112
views
How to change window title of the base workspace of MATLAB Desktop GUI of R2025a onwards on Windows
How do you change window title of the base workspace of MATLAB desktop GUI for R2025a onwards on Windows 10?
Prior to R2025a, mlservices gives an API:
desktop = com.mathworks.mlservices....
1
vote
0
answers
96
views
Error in converting symbolic value to numerical value with subs()
I have a problem in MATLAB.
I want to calculate the nonlinear system of equation using Newton Method. This nonlinear system of equation is taken from finite difference method. The system is Ay=F(y) ...
0
votes
0
answers
64
views
Applying a gain to a bus while preserving the signal name assignments
I have a bus if signals in MATLAB Simulink and I want to apply a gain to modify the signal values but preserve the naming elements of the bus, but when I apply a gain to the bus the output is just a ...
2
votes
2
answers
188
views
How to check whether a name is a locally accessible function?
How to check whether a name is a locally accessible function and only locally accessible?
For example, with
function out = top_level_function(name)
% ???
function helper2
end
end
function ...
2
votes
1
answer
202
views
How to filter and sum elements of a matrix in MATLAB based on multiple conditions without a loop?
I have the following numeric matrix in MATLAB:
A = [3 2 7; 9 1 4; 5 6 8];
I want to sum all elements that are greater than 5 and are also even.
I need to do this without using a loop, and store the ...
1
vote
1
answer
136
views
Python read matlab .mat file containing table
I'm trying to read a matlab .mat file (v7.3) from python. The thing is one of the field in the .mat object is a table (7x6) with named columns, and every time I read the object I only get a 1x6 array ...
0
votes
0
answers
46
views
dSpace MicroLabBox Tx serial communications is writing transmissions straight to the receive buffer
I am using the dSpace MicroLabBox and am running their Real-Time Interface (RTI1202) on MATLAB 2024b. I am currently attempting to control a motor through RS485. I have the connection working and the ...
-1
votes
1
answer
32
views
Simulink 3DOF block not accounting for gravity?
im very new to Simulink and wanted to experiment with the 3DOF (Body Axels) block in Simulink. However my height is just constantly increasing even with no force applied. (I tried applying thrust for ...
4
votes
1
answer
118
views
An issue with `parfor` in MATLAB R2023a--R2025a
Consider two MATLAB m files named profile.m and try_parfor.m as follows.
% profile.m
function profile()
olddir = pwd();
cd(tempdir);
fprintf('\nCurrent directory: %s\n', pwd());
func ...
0
votes
0
answers
48
views
How to command live script to scroll to the bottom left corner of an output matrix
To show the bottom left of the matrix, I am manually scrolling down to the bottom of the matrix. I seek a command that will scroll down to the bottom left of the matrix. I do not want to crop the ...
0
votes
0
answers
75
views
Weird Results in Robot Pathfinding Algorithm Testing Using MATLAB
Recently, I developed a MATLAB-based simulation to evaluate my robot pathfinding algorithm. The robots operate on a network of unidirectional tracks, where each robot computes a single path from its ...
0
votes
1
answer
118
views
MatLab 2025a Error switching the .NET Framework Error using dotnetenv
The framework is already loaded immediately after restarting Matlab 2025a.
Error using dotnetenv
.NET is loaded. To change the environment, restart MATLAB then call dotnetenv.
Test code directly ...
1
vote
0
answers
20
views
Simulink inverse kinematics block goes unstable when RPY is time-varying (homogeneous transformation matrix)
I'm trying to use the MATLAB robotics toolbox, specifically with the inverse kinematics block. I started only giving the block the translation coordinates, and a weight vector of [0 0 0 1 1 1], which ...
4
votes
1
answer
77
views
How to find an sgtitle in a figure with a tiledlayout?
I have a figure with a tiledlayout. If I create an sgtitle I am unable to find that same sgtitle within the fh.Children structure. If I do not create a tiledlayout, then the sgtitle shows up in the ...
3
votes
1
answer
61
views
How to read multi-line input from clipboard at once?
How do you read multi-line input from clipboard at once?
I tried using input but line change appears treated as Enter pressing.
>> x=input(char.empty,'s');
2020
2037
2054
2131
ans =
...
6
votes
1
answer
148
views
More than one dot in legend
I have created the first figure using legend normally.
I would like to have more than one dot in the legend, so the colours are easier to recognize there, as in the second figure (which I created ...
0
votes
0
answers
64
views
How to install libgfortran.3 on Mac Silicon for an old program
I need to run an old program that depends on MATLAB on my Mac with Apple Silicon, but I only have the precompiled binaries, not the .f source files. The program requires libgfortran.3, but modern ...
0
votes
0
answers
52
views
MATLAB Simulink error when trying to pass variables through function
I have three function blocks in my simulink model; A, B, C. I am feeding block A with data 'waypoints', which is an 11x2 array. I want block A to create a 'passthrough' for 'waypoints', such that ...
2
votes
1
answer
50
views
Programmatically fix title to same height in tiledlayout (after movement from yticklabels)
Is there a way to fix the position of left-aligned axis titles regardless of the yticklabels?
I am programmatically generating a series of axis objects, where the yticklabels are being autogenerated. ...
0
votes
0
answers
84
views
Trying to graph of the relationship of the frequency and wave number of the spin wave
I've been trying to make this code into a function and gather the wave number, but how do I get the frequency and then collect the data bt changing the wave number and then graphing. Below here is the ...
0
votes
0
answers
69
views
Decomposition of a large matrix in CP format (sum of products of matrices)
I have a matrix A of size n^2 by n^2, and I wanted to know if for a given accuracy (or a number r) there is a way to express A as the sum of Bi kron Ci for i=1...R
where Bi, Ci are n by n? i.e.
...
0
votes
0
answers
52
views
Cannot successfully set input from workspace for Simulink test harness
I am trying to use the test harness to verify the function of my Simulink model. I set the input from Workspace, and write a .m file to build the input structure(I got embedded bus element in my bus ...
0
votes
0
answers
37
views
Why does MATLAB selfAttentionLayer give different parameter counts for head/key-channel pairs with the same total key dimension?
I’m experimenting with the MathWorks example that inserts a multi-head self-attention layer into a simple CNN for the DigitDataset:
Link to example
layers = [
imageInputLayer([28 28 1])
...
6
votes
4
answers
275
views
How to unpack a buffer of 12-bit values into an array of normalized float32
A measurement system (in our lab) produces data of 12 bits per sample in a packed format, i.e. 2 samples of 12 bits each are packed into 3 bytes:
buf[l + 2] | buf[l + 1] | buf[l + 0]
7 6 5 ...
0
votes
0
answers
105
views
PID function equivalent from MATLAB to Python
I manage to correctly simulate a closed loop with Simulink using pure python "control" library. However, I'm now trying to do the same with a new closed loop that has uses a PID controller:
...
0
votes
0
answers
84
views
How to include two named functions sequentially in one anonymous function
How do you include two named functions, which are not nested, in one anonymous function?
For example, say I have a file mainFunction.m which contains
function varargout = mainFunction(in1)
% in1 is ...
1
vote
0
answers
38
views
DAQ stops during AlazarWaitAsyncBufferComplete() call - how to maintain background operation?
I'm using a MATLAB DAQ for triggering and an Alazar digitizer (ATS-9352) for data acquisition. The DAQ stops its background operation when I call AlazarWaitAsyncBufferComplete(), but I need both to ...
3
votes
1
answer
83
views
How to return a vector of strings (or chars) when input data is an object with chars (not concatenated chars)
If I have a class like this:
classdef Person
properties
Name
Age
Weight
end
methods
function obj = Person(name, age, weight)
obj.Name = name;
obj.Age = age;
obj....
3
votes
1
answer
69
views
Plotting a parametric surface where the domain is non-rectangular
Hey I'm teaching a calculus course, and for an example in my lecture on surface integrals I would like to generate a surface plot in MATLAB of a portion of a circular cylinder. Here is my MATLAB code ...
5
votes
5
answers
161
views
How can I quickly enable or disable single terms in a long sum?
I have a long expression of the (simplified) form x = 1 + 2 + 3 + 4 + 5 that I would like to "play around with" by quickly excluding or including specific numbers from the sum.
My idea was ...
5
votes
1
answer
135
views
std::format in a mex file
I'm trying to use std::format in a mex file but get an unresolved external symbol error when I use std as a module.
// test_mex.cpp
#include "mex.h"
import std;
void mexFunction(int nlhs, ...