Results for
Three former MathWorks employees, Steve Wilcockson, David Bergstein, and Gareth Thomas, joined the ArrayCast pod cast to discuss their work on array based languages. At the end of the episode, Steve says,
> It's a little known fact about MATLAB. There's this thing, Gareth has talked about the community. One of the things MATLAB did very, very early was built the MATLAB community, the so-called MATLAB File Exchange, which came about in the early 2000s. And it was where people would share code sets, M files, et cetera. This was long before GitHub came around. This was well ahead of its time. And I think there are other places too, where MATLAB has delivered cultural benefits over and above the kind of core programming and mathematical capabilities too. So, you know, MATLAB Central, File Exchange, very much saw the future.
Listen here: The ArrayCast, Episode 79, May 10, 2024.
Hey guys! I'm undergraduate in aerospace engineering at Brazil and I has done researchs in aeroelasticity fields in the last years.
Recently, I start to use dde23 for solve problems involved time-delay and active control. However, in my last code, I found some problems and I'd like some help for understand what is going wrong. Below, It's the code I'm using.
clc
close all
clear
%% Definicao das variaveis
% Caracteristicas do escoamento
rho = 1; % densidade do escoamento
c0 = 1.0; c1 = 0.165; c2 = 0.0455; c3 = 0.335; c4 = 0.3; % coeficientes de Wagner
omega_c = 17.83; % frequencia critica de flutter
Uc = 26.8903;
U = 1.20 * Uc;
% Caracteristicas do aerofolio
a = -0.15; % distancia entre eixo de referencia e o CE
b = 0.5; % semicorda
m = 20; % massa do aerofolio
H_alpha = 7; % nao-linearidade estrutural - hardening
omega_h = 2*pi; % frequencia natural de plunge
omega_alpha = 6*pi; % frequencia natural de pitch
x_alpha = 0.25; % distancia entre CG e CE
r_alpha = 0.75; % raio de giracao do aerofolio
% Caracteristicas do nonlinear energy sink
delta = 0.75; % posicao adimensional
gamma_n = 5e5; % rigidez adimensional
mi_n = 0.10; % razao de massa
lambda_n_c = (sqrt(3) / 3) * mi_n * omega_c;
lambda_n = 0.5 * lambda_n_c; % amortecimento adimensional
G = 1;
%% Definindo a solucao do sistema
tspan = 0:0.1:120; % vetor temporal
history = [0; deg2rad(1); 0; 0; 0; 0; 0; 0]; % historico para t < 0
delays = [1; 1; 1; 1]; % definicao do delay para as variaveis: xi, alpha, up e xb
ddefun = @(t, y, Z) dydt(t, y, Z, m, a, b, r_alpha, x_alpha, omega_h, omega_alpha, H_alpha, G, mi_n, lambda_n, gamma_n, delta, rho, U, c0, c1, c2, c3, c4);
sol = dde23(ddefun, delays, history, tspan);
%%
function dydt = dydt(t, y, Z, m, a, b, r_alpha, x_alpha, omega_h, omega_alpha, H_alpha, G, mi_n, lambda_n, gamma_n, delta, rho, U, c0, c1, c2, c3, c4)
% transformacao das quatro equacoes que regem a dinamica do sistema
% em oito equacoes - variaveis de estados - com o objetivo de reduzir a
% ordem do sistema:
% xi = y(1); alpha = y(2); up = y(3); xb = y(4);
% xi_d = y(5); alpha_d = y(6); up_d = y(7); xb_d = y(8)
xi_delay = Z(:,1);
alpha_delay = Z(:,2);
up_delay = Z(:,3);
xb_delay = Z(:,4);
y_tau = [xi_delay; alpha_delay; up_delay; xb_delay];
M1 = [1, x_alpha, 0, 0; x_alpha, r_alpha^2, 0, 0; mi_n, -delta*mi_n, -mi_n, 0; 0, 0, 0, 1];
M2 = (pi*rho*b^2/m) * [-1, a, 0, 0; 0, -(1/8+a^2), 0, 0; 0, 0, 0, 0; 0, 0, 0, 0];
M = M1 - M2;
C1 = [0, 0, lambda_n, 0; 0, 0, -delta*lambda_n, 0; 0, 0, -lambda_n, 0; -1, -(1/2-a), 0, (c2+c4)*U/b];
C2 = [2*pi*rho*U*b^2*(c0-c1-c3)*(-1/(m*b)), (pi*rho*b^3*(U/b)+2*pi*rho*U*b^2*(c0-c1-c3)*(1/2-a))*(-1/(m*b)), 0, 2*pi*rho*U*b^2*(U/b)*(c1*c2+c3*c4)*(-1/(m*b));
2*pi*rho*U*b^3*(c0-c1-c3)*(1/2+a)*(1/(m*b^2)), (-pi*rho*b^4*(1/2-a)*(U/b)+2*pi*rho*U*b^3*(1/2+a)*(c0-c1-c3)*(1/2-a))*(1/(m*b^2)), 0, 2*pi*rho*U*b^3*(U/b)*(c1*c2+c3*c4)*(1/2+a)*(1/(m*b^2));
0, 0, 0, 0; 0, 0, 0, 0];
C = C1 - C2;
K1 = [omega_h^2, 0, gamma_n*y(3)^2, 0; 0, (omega_alpha*r_alpha)^2*(1+H_alpha*y(2)^2), -delta*gamma_n*y(3)^2, 0;
0, 0, -gamma_n*y(3)^2, 0; 0, -(U/b), 0, c2*c4*(U/b)];
K2 = [G/m, (2*pi*rho*U*b^2*(c0-c1-c3)*(U/b)*(-1/(m*b)))-(G/m*delta), -G/m, 2*pi*rho*U*b^2*(U/b)^2*(c2*c4)*(c1+c3)*(-1/(m*b));
-G/m*delta, (2*pi*rho*U*b^3*(c0-c1-c3)*(1/2+a)*(U/b)*(1/(m*b^2)))+(G/m*delta^2), G/m*delta, 2*pi*rho*U*b^3*(U/b)^2*(1/2+a)*(c2*c4)*(c1+c3)*(1/(m*b^2));
-G/m, G/m*delta, G/m, 0; 0, 0, 0, 0];
K = K1 - K2;
T = [-G/m, G/m*delta, G/m, 0; G/m*delta, -G/m*delta^2, -G/m*delta, 0; G/m, -G/m*delta, -G/m, 0; 0, 0, 0, 0];
N = zeros(4, 4);
I = eye(4);
A = [N, I; M\-K, M\-C];
B = [N; M\T];
dydt = A*y + B*y_tau;
end
This topic is for discussing highlights to the current R2025a Pre-release.
So you've downloaded the R2025a pre-release, tried Dark mode and are wondering what else is new. A lot! A lot is new!
One thing I am particularly happy about is the fact that Apple Accelerate is now the default BLAS on Apple Silicon machines. Check it out by doing
>> version -blas
ans =
'Apple Accelerate BLAS (ILP64)'
If you compare this to R2024b that is using OpenBLAS you'll see some dramatic speed-ups in some areas. For example, I saw up to 3.7x speed-up for matrix-matrix multiplication on my M2 Mabook Pro and 2x faster LU factorisation.
Details regarding my experiments are in this blog post Life in the fast lane: Making MATLAB even faster on Apple Silicon with Apple Accelerate » The MATLAB Blog - MATLAB & Simulink . Back then you had to to some trickery to switch to Apple Accelerate, now its the default.
I just published a blog post called "The Story of TIMEIT." I've been thinking about writing something like this ever since Mike Croucher's tic/toc blog post last spring.
There were a lot of opinions about TIMEIT expressed in the comments of that blog post, including some of mine.
My blog post today gives a more full history of the function, its design goals, and how it works. I thought it might prompt more discussion, so I'm creating this thread as a place for it.
If you are an interested user of TIMEIT, feel free to weigh in here with your thoughts. Perhaps the thread will influence MathWorks regarding what to do with TIMEIT, or with related performance measurement capabilities.
Hi
If you have used the playground and are familiar with its capabilities, I will be very interested in your opinion about the tool.
Thank you in advance for your reply/opinion.
At
I am trying to run a scipt I from File Exchange, but I am getting error "Error using fsolve (line 186) FSOLVE requires at least two input arguments" Can please help fix the error?
% Prepare the options for the solver
options = prepareOptionsForSolver(options, 'fsolve');
end
if nargin == 0
error(message('optim:fsolve:NotEnoughInputs')) (line 186)
Hello everyone! Can I have some files about VPP Virtual Power Plants research for reference during my studies? Please help me.
how can i open .lod extension and .iqd extension file in matlab?
Hi everyone
The R2025a pre-release is now available to licensed users. I highly encourage you to download, give it a try and give us some feedback.
The first thing I tried was switching to Dark mode. Here's the magic
>> s = settings;
>> s.matlab.appearance.MATLABTheme.PersonalValue = "Dark";

% 读取语音信号
try
[audio, fs] = audioread('floating.m4a');
% 输出读取到的音频数据的基本信息
fprintf('成功读取m4a文件,音频数据长度: %d,采样频率: %d\n', length(audio), fs);
catch ME
warning('无法读取m4a文件,尝试转换为wav格式');
try
[audio, fs] = audioread('floating.wav');
% 输出读取到的音频数据的基本信息
fprintf('成功读取wav文件,音频数据长度: %d,采样频率: %d\n', length(audio), fs);
catch ME2
error('无法读取任何格式的音频文件,错误信息: %s', ME2.message);
end
end
% 检查audio的数据类型
if ~isnumeric(audio)
audio = double(audio);
end
% 如果是多通道音频,转换为单通道
if size(audio, 2) > 1
audio = audio(:, 1);
end
% 对信号进行填充,使其长度为2的幂次方
len = length(audio);
next_pow2 = pow2(nextpow2(len));
if len < next_pow2
padding = zeros(next_pow2 - len, 1);
audio = [audio; padding];
end
% 检查audio是否为向量且非空
if ~isvector(audio) || isempty(audio)
error('audio必须是一个非空向量');
end
% 检查audio中的元素是否都是实数
if ~all(isreal(audio))
non_real_indices = find(~isreal(audio));
audio(non_real_indices) = real(audio(non_real_indices));
fprintf('检测到并处理了非实数元素\n');
end
% 再次确认audio的数据类型为double
if ~strcmp(class(audio), 'double')
audio = double(audio);
end
% 检查audio数据的统计信息
audio_mean = mean(audio);
audio_std = std(audio);
fprintf('音频数据的均值: %f,标准差: %f\n', audio_mean, audio_std);
% 调试输出audio的部分信息
fprintf('去噪前音频数据的前5个值: %f, %f, %f, %f, %f\n', audio(1), audio(2), audio(3), audio(4), audio(5));
% 1. 去噪
% 检查分解层数是否合理
max_decomposition_level = floor(log2(length(audio)));
if decomposition_level > max_decomposition_level
warning('设置的分解层数过高,将调整为最大可能层数 %d', max_decomposition_level);
decomposition_level = max_decomposition_level;
else
decomposition_level = 3;
end
% 检查小波函数、阈值规则等参数
valid_wavelets = {'sym4', 'db1', 'db2', 'haar'}; % 一些常见的有效小波函数
if ~ismember('sym4', valid_wavelets)
error('当前小波函数不被支持,请更换为有效的小波函数');
end
valid_threshold_rules = {'sqtwolog', 'rigrsure', 'heursure', 'minimaxi'}; % 一些常见的有效阈值规则
if ~ismember('sqtwolog', valid_threshold_rules)
error('当前阈值选择规则不被支持,请更换为有效的阈值规则');
end
% 尝试使用wdencmp函数进行小波去噪
% 这里设置KeepAPP为1,表示保留近似系数
[denoised_audio,~,~] = wdencmp('gbl', audio,'sym4', decomposition_level, 'sqtwolog', 'h', 1);
% 去除填充部分
denoised_audio = denoised_audio(1:len);
% 2. 归一化
normalized_audio = denoised_audio / max(abs(denoised_audio));
% 3. 加窗和分帧
window_size = 256; % 窗长
frame_shift = 128; % 帧移
window = hamming(window_size); % 汉明窗
% 分帧
num_frames = floor((length(normalized_audio) - window_size) / frame_shift) + 1;
frames = zeros(window_size, num_frames);
for i = 1:num_frames
start_index = (i - 1) * frame_shift + 1;
frames(:, i) = normalized_audio(start_index:start_index + window_size - 1).* window;
end
% 4. 频谱分析
% 使用spectrogram函数
noverlap = window_size - frame_shift;
[S, F, T] = spectrogram(normalized_audio, window, noverlap, num_fft, fs);
S = 10 * log10(abs(S));
% 5. 绘制频谱图
figure;
surf(T, F, S);
shading interp;
xlabel('Time (s)');
ylabel('Frequency (Hz)');
zlabel('Magnitude (dB)');
title('Spectrogram of Speech Signal');
>> Untitled3
成功读取m4a文件,音频数据长度: 479232,采样频率: 48000
音频数据的均值: 0.000000,标准差: 0.019026
去噪前音频数据的前5个值: 0.000000, 0.000000, 0.000000, 0.000000, 0.000000
***************************************
ARGUMENTS ERROR
---------------------------------------
wdencmp ---> real(s) => 0 , expected
***************************************
错误使用 wdencmp (line 91)
Invalid argument value.
出错 Untitled3 (line 83)
[denoised_audio,~,~] = wdencmp('gbl', audio,'sym4', decomposition_level, 'sqtwolog', 'h', 1);
in the below code write is working fine, but read is failing ( 404 error) can you please help me reslove this.
/*
Go to thingspeak.com and create an account if you don't have one already.
After logging in, click on the "New Channel" button to create a new channel for your data. This is where your data will be stored and displayed.
Fill in the Name, Description, and other fields for your channel as desired, then click the "Save Channel" button.
Take note of the "Write API Key" located in the "API keys" tab, this is the key you will use to send data to your channel.
Replace the channelID from tab "Channel Settings" and privateKey with "Read API Keys" from "API Keys" tab.
Replace the host variable with the thingspeak server hostname "api.thingspeak.com"
Upload the sketch to your ESP32 board and make sure that the board is connected to the internet. The ESP32 should now send data to your Thingspeak channel at the intervals specified by the loop function.
Go to the channel view page on thingspeak and check the "Field1" for the new incoming data.
You can use the data visualization and analysis tools provided by Thingspeak to display and process your data in various ways.
Please note, that Thingspeak accepts only integer values.
You can later check the values at https://thingspeak.com/channels/2005329
Please note that this public channel can be accessed by anyone and it is possible that more people will write their values.
*/
#include <WiFi.h>
const char *ssid = "xxxx"; // Change this to your WiFi SSID
const char *password = "xxxxx"; // Change this to your WiFi password
const char *host = "api.thingspeak.com"; // This should not be changed
const int httpPort = 80; // This should not be changed
const String channelID = "2805914"; // Change this to your channel ID
const String writeApiKey = "xxxxxxxxxxxxxxxx"; // Change this to your Write API key
const String readApiKey = "xxxxxxxxxxxxxxxx"; // Change this to your Read API key
// The default example accepts one data filed named "field1"
// For your own server you can ofcourse create more of them.
int field1 = 20;
//int field1 = 20;
int numberOfResults = 1; // Number of results to be read
int fieldNumber = 1; // Field number which will be read out
void setup() {
Serial.begin(115200);
while (!Serial) {
delay(100);
}
// We start by connecting to a WiFi network
Serial.println();
Serial.println("******************************************************");
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void readResponse(NetworkClient *client) {
unsigned long timeout = millis();
while (client->available() == 0) {
if (millis() - timeout > 5000) {
Serial.println(">>> Client Timeout !");
client->stop();
return;
}
}
// Read all the lines of the reply from server and print them to Serial
while (client->available()) {
String line = client->readStringUntil('\r');
Serial.print(line);
}
Serial.printf("\nClosing connection\n\n");
}
void loop() {
NetworkClient client;
String footer = String(" HTTP/1.1\r\n") + "Host: " + String(host) + "\r\n" + "Connection: close\r\n\r\n";
// WRITE --------------------------------------------------------------------------------------------
if (!client.connect(host, httpPort)) {
return;
}
client.print("GET /update?api_key=" + writeApiKey + "&field1=" + field1 + footer);
readResponse(&client);
delay(200);
// READ --------------------------------------------------------------------------------------------
String readRequest = "GET /channels/" + channelID + "/fields/" + fieldNumber + ".json?results=" + numberOfResults + " HTTP/1.1\r\n" + "Host: " + host + "\r\n"
+ "Connection: close\r\n\r\n";
if (!client.connect(host, httpPort)) {
return;
}
client.print(readRequest);
readResponse(&client);
// -------------------------------------------------------------------------------------------------
//++field1;
delay(10000);
}
The Most Accepted Badge and Top Downloads Badge are two prestigious annual honors that recognize outstanding contributions in MATLAB Answers and File Exchange.
Most Accepted badge is awarded to the top 10 contributors whose answers received the most acceptances. Top Downloads badge goes to the top 10 contributors with the highest number of downloads for their submissions. Please note that, starting in 2025, the criteria for Top Downloaded Badge in will be adjusted to only count downloads from files created or updated in 2025.


In 2024, the recipients for Most Accepted are: @Voss, @Walter Roberson, @Star Strider, @Torsten, @Matt J, @Stephen23, @Steven Lord, @Hassaan, @Sam Chak, and @Cris LaPierre.
The recipients for Top Downloaded are: @Steve Miller, @Rodney Tan, @Yair Altman, @Chad Greene, @William Thielicke, @Seyedali Mirjalili, @John D'Errico, @Giampiero Campa, @Toshiaki Takeuchi, and @Zhaoxu Liu / slandarer.
Congratulations and thank you again for your outstanding contributions in 2024!
I have 4DOF system second order that time varying i ask how to solve that in simulink ?
now i try to solve the system as linear and then i try to solve it nonlinear, so i need 2 exampls please.
thanks.
Let's celebrate what made 2024 memorable! Together, we made big impacts, hosted exciting events, and built new apps.


Resource links:
Thingspeak

Thingspeak channel shows a "watch" - "un-watch" selection box. What does this do?
Thanks
Whether the computation of codes is still operating for matlab online after I close the website?
How does MATLAB app designer call external. m functions after packaging into exe? Please note that this external function is not packaged into EXE. Who can help me! I have tried commands such as' addpath ',' filread ',' eval ', but after testing, none of them worked.