Fzero not converging, giving previous answer back.
Im trying to solve the water level across a fixed lip spillway by using fzero, but I ran into the problem that the function gives an initial answer and doesn’t change between iterations in my for loop. By manually advancing throuhg the loops i can see that in the first one fzero already begins drifting and stops converging on an answer, giving me my last iterations (the first ever answer it got) back to me.
close all
clear all
clc
%% Que longitud de aliviadero necesito para aliviar hasta un calado determinado con la entrada de un caudal dado?
%%
%determino caudal de entrada
Poblacion=10000;
Dotacion=200; %l/hab*dia
coef_aguas_negras=0.8;%cuanto agua dotada pasa a aguias negras
coef_punta=2; %coeficiente de punta de aguas residuales pico comparada con caudal medio, 2 en poblaciones pequeñas (desfavorable)
Q_diario=Poblacion*Dotacion*coef_aguas_negras*1/1000%pasamos a m3/dia
Q_med=Q_diario/(24*3600) %dividimos el caudal a lo largo del dia y lo pasamos a m3/s
Q_punta=coef_punta*Q_med
Q_gris=10*Q_med%caudal a partir del cual se determina agua gris y está suficientemente diluido como para verter a cauce sin tratar (aliviadero vierte a partir de este caudal)
%%
%dimensiones de tubería a aliviar
%tomo tubería rectangular para este ejemplo
b=1
%para calcular c se necesita calcular la velocidad de flujo por el conducto
%(V=Q/A)
i=0.001 %pendiente del fondo del 1 por mil
n=0.015
%uso manning para conseguir c
ec1=@(y) 1/n*((b*y)/(b+2*y))^(2/3)*i^(1/2)*b*y-Q_gris;
y=fzero(ec1,1);
%redondeo hacia arriba (los 10 cm hacia arriba)
c=ceil(y*10)/10;
%%
%creo el espacio del vector de puntos diferenciales a lo largo del
%aliviadero
L=5;
dx=0.1;
x=[0:dx:L];
%%
%INPUT
%meto el nivel al principio del aliviadero (se saca igual con manning
%arriba si tenemos un caudal de entrada
Q=1;
ec2=@(y) 1/n*((b*y)/(b+2*y))^(2/3)*i^(1/2)*[b*y]-Q;
%%
h1=zeros(1,length(x)-1);
h2=zeros(1,length(x)-1);
v1=zeros(1,length(x)-1);
v2=zeros(1,length(x)-1);
y1=fzero(ec2,1);
h1(1)=y1;
v_e=Q/(b*h1(1));
v1(1)=v_e;
q1=Q;
Q1(1)=q1;
Cv=1.86; %para la formula de aliviadero de pared delgada
g=9.81;
ec3=@(y2) 10^16*([y1]+[((v_e)^2)/(2*g)]-[y2]-[(((q1-Cv*dx*(((y1+y2)/2)-c)^(3/2))/(b*y2))^2)/(2*g)]-[sqrt(((((v_e+((q1-Cv*dx*(((y1+y2)/2)-c)^(3/2))/(b*y2))))/2)*n*((b+2*y2)^(2/3)))/((b*y2)^(2/3)))*dx]);
a=fzero(ec3,10);
y2=a;
h2(1)=y2;
q2=(q1-Cv*dx*(((y1+y2)/2)-c)^(3/2));
Q2(1)=q2;
v2(1)=q2/(b*h2(1));
%%
for k=2:length(x)
y1=h2(k-1);
v_e=v2(k-1);
q1=Q2(k-1);
a=fzero(ec3,10);
y2=a;
h2(k)=y2;
q2=(q1-Cv*dx*(((y1+y2)/2)-c)^(3/2));
Q2(k)=q2;
v2(k)=q2/(b*h2(k));
h1(k)=y1;
v1(k)=v_e;
end
%%
%intento diagnosticar el error de convergencia de fzero
figure ;
fplot(ec3,[-2,2]);
hold on
plot(y2,0,’r*’);
yline(0);
hold off
k=2;
y1=h2(k-1);
v_e=v2(k-1);
q1=Q2(k-1);
[a,fval,exitflag,output]=fzero(ec3,10)
drift=[y1]+[((v_e)^2)/(2*g)]-[y2]-[(((q1-Cv*dx*(((y1+y2)/2)-c)^(3/2))/(b*y2))^2)/(2*g)]-[sqrt(((((v_e+((q1-Cv*dx*(((y1+y2)/2)-c)^(3/2))/(b*y2))))/2)*n*((b+2*y2)^(2/3)))/((b*y2)^(2/3)))*dx];
figure ;
fplot(ec3,[-2,2]);
hold on
plot(y2,0,’r*’);
yline(0);
hold offIm trying to solve the water level across a fixed lip spillway by using fzero, but I ran into the problem that the function gives an initial answer and doesn’t change between iterations in my for loop. By manually advancing throuhg the loops i can see that in the first one fzero already begins drifting and stops converging on an answer, giving me my last iterations (the first ever answer it got) back to me.
close all
clear all
clc
%% Que longitud de aliviadero necesito para aliviar hasta un calado determinado con la entrada de un caudal dado?
%%
%determino caudal de entrada
Poblacion=10000;
Dotacion=200; %l/hab*dia
coef_aguas_negras=0.8;%cuanto agua dotada pasa a aguias negras
coef_punta=2; %coeficiente de punta de aguas residuales pico comparada con caudal medio, 2 en poblaciones pequeñas (desfavorable)
Q_diario=Poblacion*Dotacion*coef_aguas_negras*1/1000%pasamos a m3/dia
Q_med=Q_diario/(24*3600) %dividimos el caudal a lo largo del dia y lo pasamos a m3/s
Q_punta=coef_punta*Q_med
Q_gris=10*Q_med%caudal a partir del cual se determina agua gris y está suficientemente diluido como para verter a cauce sin tratar (aliviadero vierte a partir de este caudal)
%%
%dimensiones de tubería a aliviar
%tomo tubería rectangular para este ejemplo
b=1
%para calcular c se necesita calcular la velocidad de flujo por el conducto
%(V=Q/A)
i=0.001 %pendiente del fondo del 1 por mil
n=0.015
%uso manning para conseguir c
ec1=@(y) 1/n*((b*y)/(b+2*y))^(2/3)*i^(1/2)*b*y-Q_gris;
y=fzero(ec1,1);
%redondeo hacia arriba (los 10 cm hacia arriba)
c=ceil(y*10)/10;
%%
%creo el espacio del vector de puntos diferenciales a lo largo del
%aliviadero
L=5;
dx=0.1;
x=[0:dx:L];
%%
%INPUT
%meto el nivel al principio del aliviadero (se saca igual con manning
%arriba si tenemos un caudal de entrada
Q=1;
ec2=@(y) 1/n*((b*y)/(b+2*y))^(2/3)*i^(1/2)*[b*y]-Q;
%%
h1=zeros(1,length(x)-1);
h2=zeros(1,length(x)-1);
v1=zeros(1,length(x)-1);
v2=zeros(1,length(x)-1);
y1=fzero(ec2,1);
h1(1)=y1;
v_e=Q/(b*h1(1));
v1(1)=v_e;
q1=Q;
Q1(1)=q1;
Cv=1.86; %para la formula de aliviadero de pared delgada
g=9.81;
ec3=@(y2) 10^16*([y1]+[((v_e)^2)/(2*g)]-[y2]-[(((q1-Cv*dx*(((y1+y2)/2)-c)^(3/2))/(b*y2))^2)/(2*g)]-[sqrt(((((v_e+((q1-Cv*dx*(((y1+y2)/2)-c)^(3/2))/(b*y2))))/2)*n*((b+2*y2)^(2/3)))/((b*y2)^(2/3)))*dx]);
a=fzero(ec3,10);
y2=a;
h2(1)=y2;
q2=(q1-Cv*dx*(((y1+y2)/2)-c)^(3/2));
Q2(1)=q2;
v2(1)=q2/(b*h2(1));
%%
for k=2:length(x)
y1=h2(k-1);
v_e=v2(k-1);
q1=Q2(k-1);
a=fzero(ec3,10);
y2=a;
h2(k)=y2;
q2=(q1-Cv*dx*(((y1+y2)/2)-c)^(3/2));
Q2(k)=q2;
v2(k)=q2/(b*h2(k));
h1(k)=y1;
v1(k)=v_e;
end
%%
%intento diagnosticar el error de convergencia de fzero
figure ;
fplot(ec3,[-2,2]);
hold on
plot(y2,0,’r*’);
yline(0);
hold off
k=2;
y1=h2(k-1);
v_e=v2(k-1);
q1=Q2(k-1);
[a,fval,exitflag,output]=fzero(ec3,10)
drift=[y1]+[((v_e)^2)/(2*g)]-[y2]-[(((q1-Cv*dx*(((y1+y2)/2)-c)^(3/2))/(b*y2))^2)/(2*g)]-[sqrt(((((v_e+((q1-Cv*dx*(((y1+y2)/2)-c)^(3/2))/(b*y2))))/2)*n*((b+2*y2)^(2/3)))/((b*y2)^(2/3)))*dx];
figure ;
fplot(ec3,[-2,2]);
hold on
plot(y2,0,’r*’);
yline(0);
hold off Im trying to solve the water level across a fixed lip spillway by using fzero, but I ran into the problem that the function gives an initial answer and doesn’t change between iterations in my for loop. By manually advancing throuhg the loops i can see that in the first one fzero already begins drifting and stops converging on an answer, giving me my last iterations (the first ever answer it got) back to me.
close all
clear all
clc
%% Que longitud de aliviadero necesito para aliviar hasta un calado determinado con la entrada de un caudal dado?
%%
%determino caudal de entrada
Poblacion=10000;
Dotacion=200; %l/hab*dia
coef_aguas_negras=0.8;%cuanto agua dotada pasa a aguias negras
coef_punta=2; %coeficiente de punta de aguas residuales pico comparada con caudal medio, 2 en poblaciones pequeñas (desfavorable)
Q_diario=Poblacion*Dotacion*coef_aguas_negras*1/1000%pasamos a m3/dia
Q_med=Q_diario/(24*3600) %dividimos el caudal a lo largo del dia y lo pasamos a m3/s
Q_punta=coef_punta*Q_med
Q_gris=10*Q_med%caudal a partir del cual se determina agua gris y está suficientemente diluido como para verter a cauce sin tratar (aliviadero vierte a partir de este caudal)
%%
%dimensiones de tubería a aliviar
%tomo tubería rectangular para este ejemplo
b=1
%para calcular c se necesita calcular la velocidad de flujo por el conducto
%(V=Q/A)
i=0.001 %pendiente del fondo del 1 por mil
n=0.015
%uso manning para conseguir c
ec1=@(y) 1/n*((b*y)/(b+2*y))^(2/3)*i^(1/2)*b*y-Q_gris;
y=fzero(ec1,1);
%redondeo hacia arriba (los 10 cm hacia arriba)
c=ceil(y*10)/10;
%%
%creo el espacio del vector de puntos diferenciales a lo largo del
%aliviadero
L=5;
dx=0.1;
x=[0:dx:L];
%%
%INPUT
%meto el nivel al principio del aliviadero (se saca igual con manning
%arriba si tenemos un caudal de entrada
Q=1;
ec2=@(y) 1/n*((b*y)/(b+2*y))^(2/3)*i^(1/2)*[b*y]-Q;
%%
h1=zeros(1,length(x)-1);
h2=zeros(1,length(x)-1);
v1=zeros(1,length(x)-1);
v2=zeros(1,length(x)-1);
y1=fzero(ec2,1);
h1(1)=y1;
v_e=Q/(b*h1(1));
v1(1)=v_e;
q1=Q;
Q1(1)=q1;
Cv=1.86; %para la formula de aliviadero de pared delgada
g=9.81;
ec3=@(y2) 10^16*([y1]+[((v_e)^2)/(2*g)]-[y2]-[(((q1-Cv*dx*(((y1+y2)/2)-c)^(3/2))/(b*y2))^2)/(2*g)]-[sqrt(((((v_e+((q1-Cv*dx*(((y1+y2)/2)-c)^(3/2))/(b*y2))))/2)*n*((b+2*y2)^(2/3)))/((b*y2)^(2/3)))*dx]);
a=fzero(ec3,10);
y2=a;
h2(1)=y2;
q2=(q1-Cv*dx*(((y1+y2)/2)-c)^(3/2));
Q2(1)=q2;
v2(1)=q2/(b*h2(1));
%%
for k=2:length(x)
y1=h2(k-1);
v_e=v2(k-1);
q1=Q2(k-1);
a=fzero(ec3,10);
y2=a;
h2(k)=y2;
q2=(q1-Cv*dx*(((y1+y2)/2)-c)^(3/2));
Q2(k)=q2;
v2(k)=q2/(b*h2(k));
h1(k)=y1;
v1(k)=v_e;
end
%%
%intento diagnosticar el error de convergencia de fzero
figure ;
fplot(ec3,[-2,2]);
hold on
plot(y2,0,’r*’);
yline(0);
hold off
k=2;
y1=h2(k-1);
v_e=v2(k-1);
q1=Q2(k-1);
[a,fval,exitflag,output]=fzero(ec3,10)
drift=[y1]+[((v_e)^2)/(2*g)]-[y2]-[(((q1-Cv*dx*(((y1+y2)/2)-c)^(3/2))/(b*y2))^2)/(2*g)]-[sqrt(((((v_e+((q1-Cv*dx*(((y1+y2)/2)-c)^(3/2))/(b*y2))))/2)*n*((b+2*y2)^(2/3)))/((b*y2)^(2/3)))*dx];
figure ;
fplot(ec3,[-2,2]);
hold on
plot(y2,0,’r*’);
yline(0);
hold off fzero, convergence, exitflag=1 MATLAB Answers — New Questions
I am interafacing 8051 via serial port.How can i achieve this?
Can I use Simulink for sending the data to the 8051 via rs232?Can I use Simulink for sending the data to the 8051 via rs232? Can I use Simulink for sending the data to the 8051 via rs232? rs232, interface, serial port, microcontroller, amtel, at8051 MATLAB Answers — New Questions
How to interface Matlab/Simulink RS2328051 Micrcontroller?
How to interface Matlab/Simulink <—>RS232<—>8051 Micrcontroller?
Say for example by sending a bit signal from Matlab through RS232 to 8051, a LED should glow.
Is this possible?How to interface Matlab/Simulink <—>RS232<—>8051 Micrcontroller?
Say for example by sending a bit signal from Matlab through RS232 to 8051, a LED should glow.
Is this possible? How to interface Matlab/Simulink <—>RS232<—>8051 Micrcontroller?
Say for example by sending a bit signal from Matlab through RS232 to 8051, a LED should glow.
Is this possible? image processing, embedded matlab function, serial, programming MATLAB Answers — New Questions
How to check Serial port continuously
My task is to capture image only when char ‘A’ is received through COM port. So How to contineously monitor COM port to check whether data is received or no on COM port.My task is to capture image only when char ‘A’ is received through COM port. So How to contineously monitor COM port to check whether data is received or no on COM port. My task is to capture image only when char ‘A’ is received through COM port. So How to contineously monitor COM port to check whether data is received or no on COM port. scanning com port MATLAB Answers — New Questions
EEGLAB “pop_eeg_spektrine_galia”
When saving in the eeglab darbeliai "pop_eeg_spektrine_galia" section, there is absolute power and relational power. I am curious about the difference between them, and whether fft is applied and saved.When saving in the eeglab darbeliai "pop_eeg_spektrine_galia" section, there is absolute power and relational power. I am curious about the difference between them, and whether fft is applied and saved. When saving in the eeglab darbeliai "pop_eeg_spektrine_galia" section, there is absolute power and relational power. I am curious about the difference between them, and whether fft is applied and saved. eeglab, fft MATLAB Answers — New Questions
Update #9 for Automating Microsoft 365 with PowerShell eBook
Updated EPUB and PDF Files Available for Download
The Automating Microsoft 365 with PowerShell eBook is now at update #9. This is the March 2025 update. We release monthly updates for the PowerShell eBook around the middle of the preceding month to allow us the time to concentrate on preparing the monthly update for Office 365 for IT Pros.
The updated EPUB and PDF files are available to:
- People who bought Automating Microsoft 365 with PowerShell on its own.
- Subscribers to the Office 365 for IT Pros (2025 edition) eBook.
Please use the download link in the receipt emailed after your purchase to access the updated files. Alternatively, you can get the updated files through your Gumroad.com account. The update number (and month) is shown at the bottom of each page.
Continual Expansion of Content
The original version of Automating Microsoft 365 with PowerShell spanned about 120 pages. The book is now 300 pages (more in the paperback edition because it includes an index). When we removed the PowerShell chapter from the Office 365 for IT Pros eBook, we always knew that there was much more to say about using PowerShell with Microsoft 365. Over the last eight updates, we’ve added a ton of examples, mostly covering the use of Microsoft Graph PowerShell SDK cmdlets with workloads like Entra ID, Exchange Online, SharePoint Online, and Teams.
Update #9 continues the trend with new content covering topics like using the Sites.Selected Graph permission to control access to SharePoint Online sites, how to upload files to SharePoint Online, sending multiple attachments with Exchange Online, and using an upload session to process very large attachments. There are many other changes, rewrites, and enhancements scattered across the book, including a complete rewrite of our coverage of using Microsoft 365 PowerShell with Azure Automation.
Price, Price, Price
To reflect the increased value of the content included in Automating Microsoft 365 with PowerShell, we’ve increased the price from $12.95 to $14.95. Other books covering the use of PowerShell with Microsoft 365 are priced significantly higher, so we think that even the new price represents incredible value. We’re confident that no other book covers the number and variety of fully-worked out examples of how to use PowerShell to get work done with Microsoft 365.
We also increased the price of the paperback edition to $19.95. This is simply a function of the increased page count driving the cost we pay Amazon to print each copy on an on-demand. There’s nothing to stop anyone printing off the PDF version if you want a paper copy. The only issue you’ll run into is that the many hyperlinks (over 200 at the last count) we include in the book become unusable when printed. To get around the issue, we substitute plain-text links in the content of the paperback edition.
Subscribers of Office 365 for IT Pros don’t have to pay any extra for their copies of Automating Microsoft 365 with PowerShell.
Onto Update #10
Work has already started on update #10. We’re waiting for Microsoft to release a new version of the Microsoft Graph PowerShell SDK. V2.25 has been around for about three months now, which is much longer than the usual monthly release cadence (Figure 1).

I don’t know why Microsoft has delayed the release of V2.26. It’s certainly not to deal with the problem related to plain-text passwords reported last week. No doubt we will hear in time. In the meanwhile, the interesting thing about the information shown in Figure 1 is the dramatic usage growth for the SDK from 1.18 million downloads of V2.24 to 3.49 million downloads for V2.25. That’s probably indicative of an uptick in interest as tenants work to get off the soon-to-retire MSOL and Azure AD modules. Maybe all those folks upgrading scripts to use the Graph SDK could do with a good book?
Analyzing Sections of Table Based on One Variable
Hello,
I have a large table (we’ll say something like 8 x 100, but it will more likely having over 10,000 rows).
The last column represents "time in a day", and the 100 rows represents several days worth of data.
Everytime the day hits midnight, the last column has a value of 0.
It’s worth noting that the last column isn’t quite a single 24-hr time frame, so the last column doesn’t always increase throughout the day before it drops back to time 0.
However, there are not an equal amount of rows for each day.
So far example, Day 1 might have 18 rows, Day 2 will have 35 rows, Day 3 will have 40 rows, and Day 4 will have 7 rows.
Each Day will always begin with a value of 0 for the last column.
The total number of days and how many rows per day are both never constant (i.e. it will vary).
I don’t necessarily want to split the larger table into 4 smaller tables (after reading other forum posts it seems this can lead to many bugs and errors), although this might accomplish what I’m looking for.
Rather, I want to be able to (A) compare the first row of Day 1 and with first row of Day 2, and compare Day 1 with Day 3, etc.
Then (B) determine if the first rows of Days 1 and 2 are similar enough to not worry about Day 2’s data.
I have a script already that accomplished step B (previously I was arbitralilty splitting the larger table).
But since know I want each section from the larger table to have a unique number of rows, I’m having difficulty accomplishing this.
In pseudocode, I was starting to do something like:
for i=1:N
if LastCol(i)==0
% Save all data between point i and point right before LastCol(i)==0 again
end
end
One thing that I can have known prior to this is how many days will be in the large table.
So for example, in the above example, I will know that there are 4 days, which corresponds to 4 zeros in the last column.
If my request seems confusing or convoluted, please let me know and I can explain further or take it down.
In Short: My main issue is how I split the table up in unique sizes.
Thanks.
Edit:
I thought of a couple of for loops that sort of help my issue.
I have two matrices: One with four datapoints corresponding the running time of the first day. And one that is the whole table.
for i=1:Length_Table
for j=1:Num_Days
if Big_Table.A(i)==Day_Matrix(j)
% Not Sure
else
end
end
end
where Big_Table.A column corresponds to the overall running time (doesn’t reset after each day).
If at any time for the Big Table of Data equals a time when we know the day resets, then that’s where I want to begin a "new section" and end that section at the point before the it happens again.
I’m not sure how to do this task, however.Hello,
I have a large table (we’ll say something like 8 x 100, but it will more likely having over 10,000 rows).
The last column represents "time in a day", and the 100 rows represents several days worth of data.
Everytime the day hits midnight, the last column has a value of 0.
It’s worth noting that the last column isn’t quite a single 24-hr time frame, so the last column doesn’t always increase throughout the day before it drops back to time 0.
However, there are not an equal amount of rows for each day.
So far example, Day 1 might have 18 rows, Day 2 will have 35 rows, Day 3 will have 40 rows, and Day 4 will have 7 rows.
Each Day will always begin with a value of 0 for the last column.
The total number of days and how many rows per day are both never constant (i.e. it will vary).
I don’t necessarily want to split the larger table into 4 smaller tables (after reading other forum posts it seems this can lead to many bugs and errors), although this might accomplish what I’m looking for.
Rather, I want to be able to (A) compare the first row of Day 1 and with first row of Day 2, and compare Day 1 with Day 3, etc.
Then (B) determine if the first rows of Days 1 and 2 are similar enough to not worry about Day 2’s data.
I have a script already that accomplished step B (previously I was arbitralilty splitting the larger table).
But since know I want each section from the larger table to have a unique number of rows, I’m having difficulty accomplishing this.
In pseudocode, I was starting to do something like:
for i=1:N
if LastCol(i)==0
% Save all data between point i and point right before LastCol(i)==0 again
end
end
One thing that I can have known prior to this is how many days will be in the large table.
So for example, in the above example, I will know that there are 4 days, which corresponds to 4 zeros in the last column.
If my request seems confusing or convoluted, please let me know and I can explain further or take it down.
In Short: My main issue is how I split the table up in unique sizes.
Thanks.
Edit:
I thought of a couple of for loops that sort of help my issue.
I have two matrices: One with four datapoints corresponding the running time of the first day. And one that is the whole table.
for i=1:Length_Table
for j=1:Num_Days
if Big_Table.A(i)==Day_Matrix(j)
% Not Sure
else
end
end
end
where Big_Table.A column corresponds to the overall running time (doesn’t reset after each day).
If at any time for the Big Table of Data equals a time when we know the day resets, then that’s where I want to begin a "new section" and end that section at the point before the it happens again.
I’m not sure how to do this task, however. Hello,
I have a large table (we’ll say something like 8 x 100, but it will more likely having over 10,000 rows).
The last column represents "time in a day", and the 100 rows represents several days worth of data.
Everytime the day hits midnight, the last column has a value of 0.
It’s worth noting that the last column isn’t quite a single 24-hr time frame, so the last column doesn’t always increase throughout the day before it drops back to time 0.
However, there are not an equal amount of rows for each day.
So far example, Day 1 might have 18 rows, Day 2 will have 35 rows, Day 3 will have 40 rows, and Day 4 will have 7 rows.
Each Day will always begin with a value of 0 for the last column.
The total number of days and how many rows per day are both never constant (i.e. it will vary).
I don’t necessarily want to split the larger table into 4 smaller tables (after reading other forum posts it seems this can lead to many bugs and errors), although this might accomplish what I’m looking for.
Rather, I want to be able to (A) compare the first row of Day 1 and with first row of Day 2, and compare Day 1 with Day 3, etc.
Then (B) determine if the first rows of Days 1 and 2 are similar enough to not worry about Day 2’s data.
I have a script already that accomplished step B (previously I was arbitralilty splitting the larger table).
But since know I want each section from the larger table to have a unique number of rows, I’m having difficulty accomplishing this.
In pseudocode, I was starting to do something like:
for i=1:N
if LastCol(i)==0
% Save all data between point i and point right before LastCol(i)==0 again
end
end
One thing that I can have known prior to this is how many days will be in the large table.
So for example, in the above example, I will know that there are 4 days, which corresponds to 4 zeros in the last column.
If my request seems confusing or convoluted, please let me know and I can explain further or take it down.
In Short: My main issue is how I split the table up in unique sizes.
Thanks.
Edit:
I thought of a couple of for loops that sort of help my issue.
I have two matrices: One with four datapoints corresponding the running time of the first day. And one that is the whole table.
for i=1:Length_Table
for j=1:Num_Days
if Big_Table.A(i)==Day_Matrix(j)
% Not Sure
else
end
end
end
where Big_Table.A column corresponds to the overall running time (doesn’t reset after each day).
If at any time for the Big Table of Data equals a time when we know the day resets, then that’s where I want to begin a "new section" and end that section at the point before the it happens again.
I’m not sure how to do this task, however. matlab, if statement, table, search MATLAB Answers — New Questions
Kalman Filter – Activating or Enabling a matlab function block in simulink
Hello,
I have data of 3 signals in matlab workspace and each signal was recorded with different sampling rate. I want to use these signals in simulink however i am not sure what is the best way to do that for my case.
I have build a kalman filter in simulink that was tested using simulated data. Now I have real data which means the setup is slightly different. I want to trigger a matlab function block to be used only when data is available.
Any ideas how to do that?
Thank you.Hello,
I have data of 3 signals in matlab workspace and each signal was recorded with different sampling rate. I want to use these signals in simulink however i am not sure what is the best way to do that for my case.
I have build a kalman filter in simulink that was tested using simulated data. Now I have real data which means the setup is slightly different. I want to trigger a matlab function block to be used only when data is available.
Any ideas how to do that?
Thank you. Hello,
I have data of 3 signals in matlab workspace and each signal was recorded with different sampling rate. I want to use these signals in simulink however i am not sure what is the best way to do that for my case.
I have build a kalman filter in simulink that was tested using simulated data. Now I have real data which means the setup is slightly different. I want to trigger a matlab function block to be used only when data is available.
Any ideas how to do that?
Thank you. simulink, data import, parameter estimation, recursive estimation MATLAB Answers — New Questions
gfit error message in generalized Pareto (GP) distribution
Hello,
I compute return period using gpfit (Generalized Pareto parameter estimates) to calculate the return period, while I calculate the maximum likehood, I got an error message below.
Warning: Maximum likelihood has converged to an estimate of K < -1/2.
Confidence intervals and standard errors can not be computed reliably.> In gpfit (line 124)
I guess this happens with small values in the inputs, but I have no idea how to sort it out. Could you please help????
ThanksHello,
I compute return period using gpfit (Generalized Pareto parameter estimates) to calculate the return period, while I calculate the maximum likehood, I got an error message below.
Warning: Maximum likelihood has converged to an estimate of K < -1/2.
Confidence intervals and standard errors can not be computed reliably.> In gpfit (line 124)
I guess this happens with small values in the inputs, but I have no idea how to sort it out. Could you please help????
Thanks Hello,
I compute return period using gpfit (Generalized Pareto parameter estimates) to calculate the return period, while I calculate the maximum likehood, I got an error message below.
Warning: Maximum likelihood has converged to an estimate of K < -1/2.
Confidence intervals and standard errors can not be computed reliably.> In gpfit (line 124)
I guess this happens with small values in the inputs, but I have no idea how to sort it out. Could you please help????
Thanks pareto, statistics, (gp) distribution, extreme, gpfit, likelihood, gpd, error MATLAB Answers — New Questions
Sending Multiple Data to Excel from MATLAB?
Hi everybody,
I was wondering if it is possible to send multiple data from MATLAB to Excel in the same file?
At the moment I am using:
filename = ‘test.xlsx’
xlswrite(filename,MomentsX,1,’C1:F5′)
This only transfers the matrix ‘MomentsX’ into Excel. What If I want to send multiple data to the same spreadsheet in Excel?
Is this possible?
Many thanks in advance,
ScottHi everybody,
I was wondering if it is possible to send multiple data from MATLAB to Excel in the same file?
At the moment I am using:
filename = ‘test.xlsx’
xlswrite(filename,MomentsX,1,’C1:F5′)
This only transfers the matrix ‘MomentsX’ into Excel. What If I want to send multiple data to the same spreadsheet in Excel?
Is this possible?
Many thanks in advance,
Scott Hi everybody,
I was wondering if it is possible to send multiple data from MATLAB to Excel in the same file?
At the moment I am using:
filename = ‘test.xlsx’
xlswrite(filename,MomentsX,1,’C1:F5′)
This only transfers the matrix ‘MomentsX’ into Excel. What If I want to send multiple data to the same spreadsheet in Excel?
Is this possible?
Many thanks in advance,
Scott matlab to excel, data MATLAB Answers — New Questions
Why aren’t my Simulink functions being called properly when using nested Simulink functions, Stateflow charts, and Data Store blocks?
I used three subsystems: one subsystem contains a Stateflow chart, which includes the state. The other two subsystems contain Simulink functions, each with its own Stateflow block. I am using nested Simulink functions, and I am calling them through Stateflow. Additionally, I used Data Store blocks, but the Simulink functions are not being called properly. why? what is the reason anyone help me on that ?I used three subsystems: one subsystem contains a Stateflow chart, which includes the state. The other two subsystems contain Simulink functions, each with its own Stateflow block. I am using nested Simulink functions, and I am calling them through Stateflow. Additionally, I used Data Store blocks, but the Simulink functions are not being called properly. why? what is the reason anyone help me on that ? I used three subsystems: one subsystem contains a Stateflow chart, which includes the state. The other two subsystems contain Simulink functions, each with its own Stateflow block. I am using nested Simulink functions, and I am calling them through Stateflow. Additionally, I used Data Store blocks, but the Simulink functions are not being called properly. why? what is the reason anyone help me on that ? stateflow, simulink, functions, matlab MATLAB Answers — New Questions
Purview Retires Events Alert Capability from Unified Audit Log
Audit-Based Alerts Retired from March 25, 2025
Publish bad news on Friday is the advice for anyone who wants the news to create less of a fuss. Publishing the news late on Friday before a holiday the following Monday (U.S. Presidents’ Day) might do an even better job of suppressing criticism. Some will consider the announcement in Message center notification MC1006620 (15 February 2025) that “Purview will retire the event alerts capability within the Purview Audit solution on March 24, 2025” to be bad news. It all depends on whether you use alerts based on audit events to learn when something happens in a tenant.
Activity Alerts
Microsoft introduced activity alerts and alert policies soon after the introduction of the unified audit log in July 2015. The idea is simple. The audit log holds some extraordinarily valuable information about what happens in a tenant, but a busy tenant can generate hundreds of thousands of audit events daily. Human administrators don’t have the time to keep on checking if events of interest (for whatever reason) show up in the audit log. Computers are very good at checking data, and activity alerts are predefined checks against new audit events as workloads ingest data into the audit log. If an event of interest is found, Purview sends email to administrators to tell them about the event (Figure 1).

Better Tools to Analyze Audit Events Exist
Although useful (and still used), a case can be made that activity alerts have passed their sell-by-date. The unified audit log holds an increasing amount of data generated by workloads from Entra ID to SharePoint Online to Teams to Purview. Better tools exist to allow tenant administrators to monitor events of interest, including connecting Office 365 data to Microsoft Sentinel where the data can be analyzed along with information gleaned from other sources. Many organizations run background jobs to extract audit events from the unified audit log for ingestion into an external SIEM. There’s even a Splunk add-on to extract audit data for Microsoft 365. And if you want to involve AI, there’s Security Copilot to consider.
And if off-the-shelf software isn’t available, PowerShell can be used to extract and analyze audit events using either the Search-UnifiedAuditLog cmdlet or the AuditLogQuery Graph API. The signs are that Microsoft wants customers to use asynchronous Graph-based audit searches because these searches absorb fewer resources. Removing the monitoring of new audit events to be able to generate audit alerts seems to be another attempt to restrict the resources consumed by audit activity.
Using either the cmdlet or Graph query, the same kind of processing to find and email alerts for audit events of interest is easily done using a combination of PowerShell and scheduled Azure Automation jobs.
Confusion with DLP Alerts
Data Loss Prevention (DLP) policies can also signal alerts when policy rules detect violations. MC1006620 confuses the issue slightly by reassuring tenants that DLP alerts are unaffected by the retirement of audit-based activity alerts.
Further confusion comes about in the assertion that customers who want to retain audit-based activity policies should recreate them using DLP policies. Outside of scenarios like unusual file downloads, I’m not sure if this is even possible for some of the activities audit-based alert policies highlight. Microsoft says that they will invest their development resources on the alerts functionality within DLP, which is fine even if it might not cover everything that might be exposed in an audit event.
In any case, as noted above, a range of options exist to monitor audit events and signal alerts if something of interest is discovered.
Make sure that you’re not surprised about changes that appear inside Microsoft 365 applications by subscribing to the Office 365 for IT Pros eBook. Our monthly updates make sure that our subscribers stay informed.
Simulink Model does not run simulation – initializing never stops
Good evening,
I integrated a KULI FMU into a blank worksheet in SIMULINK, and connected an imput constant and a scope to check if the import function works.
It is compiling, starts initializing, but never finishes the initializion, and never runs the model. Any Idea how to solve that problem?
Solver configuration is set to auto.Good evening,
I integrated a KULI FMU into a blank worksheet in SIMULINK, and connected an imput constant and a scope to check if the import function works.
It is compiling, starts initializing, but never finishes the initializion, and never runs the model. Any Idea how to solve that problem?
Solver configuration is set to auto. Good evening,
I integrated a KULI FMU into a blank worksheet in SIMULINK, and connected an imput constant and a scope to check if the import function works.
It is compiling, starts initializing, but never finishes the initializion, and never runs the model. Any Idea how to solve that problem?
Solver configuration is set to auto. simulation, initalisation MATLAB Answers — New Questions
Looking for approach to import XLS data for code generation
I have XLS which contains signal names used in simulink model. With details of initial value, data type, minimum maximum value etc.
I want to "import" this xls data and load into Model Explorer . After compilation it should be possible to generate code as per signal details in xls file. Model will have the signal names present in xls file always.
Probably this is very known thing to simplify code generation. But i am not able to figure out how to do this ?
Any existing threads or solution with use of latest matlab features (below 2022b , 2017b prefered ) will be also a great help.I have XLS which contains signal names used in simulink model. With details of initial value, data type, minimum maximum value etc.
I want to "import" this xls data and load into Model Explorer . After compilation it should be possible to generate code as per signal details in xls file. Model will have the signal names present in xls file always.
Probably this is very known thing to simplify code generation. But i am not able to figure out how to do this ?
Any existing threads or solution with use of latest matlab features (below 2022b , 2017b prefered ) will be also a great help. I have XLS which contains signal names used in simulink model. With details of initial value, data type, minimum maximum value etc.
I want to "import" this xls data and load into Model Explorer . After compilation it should be possible to generate code as per signal details in xls file. Model will have the signal names present in xls file always.
Probably this is very known thing to simplify code generation. But i am not able to figure out how to do this ?
Any existing threads or solution with use of latest matlab features (below 2022b , 2017b prefered ) will be also a great help. importing excel data, embedded coder, data dictionary MATLAB Answers — New Questions
What happens if the termination condition is satisfied before the constraint in matlab’s fmincon?
I’m doing optimization using fmincon.
I used ObjectiveLimit to terminate the optimization when the size of the objective function is less than 0.2,
As I was writing the code, it seems that if the nonlinear constraints are satisfied, the termination condition is also satisfied.
However, when I run the code, the optimization is performed several times and then the code terminates.
I don’t understand this part.
Doesn’t fmincon perform optimization for cases that satisfy the constraints?
What happens if the termination condition is satisfied before the constraint in matlab’s fmincon?
Below is the output when optimization is finished.
fmincon stopped because the objective function value 6.018404e-04 is less than options.ObjectiveLimit = 2.000000e-01 and the relative maximum constraint violation 2.039171e-13 is less than options.ConstraintTolerance = 1.000000e-06
Thank you.I’m doing optimization using fmincon.
I used ObjectiveLimit to terminate the optimization when the size of the objective function is less than 0.2,
As I was writing the code, it seems that if the nonlinear constraints are satisfied, the termination condition is also satisfied.
However, when I run the code, the optimization is performed several times and then the code terminates.
I don’t understand this part.
Doesn’t fmincon perform optimization for cases that satisfy the constraints?
What happens if the termination condition is satisfied before the constraint in matlab’s fmincon?
Below is the output when optimization is finished.
fmincon stopped because the objective function value 6.018404e-04 is less than options.ObjectiveLimit = 2.000000e-01 and the relative maximum constraint violation 2.039171e-13 is less than options.ConstraintTolerance = 1.000000e-06
Thank you. I’m doing optimization using fmincon.
I used ObjectiveLimit to terminate the optimization when the size of the objective function is less than 0.2,
As I was writing the code, it seems that if the nonlinear constraints are satisfied, the termination condition is also satisfied.
However, when I run the code, the optimization is performed several times and then the code terminates.
I don’t understand this part.
Doesn’t fmincon perform optimization for cases that satisfy the constraints?
What happens if the termination condition is satisfied before the constraint in matlab’s fmincon?
Below is the output when optimization is finished.
fmincon stopped because the objective function value 6.018404e-04 is less than options.ObjectiveLimit = 2.000000e-01 and the relative maximum constraint violation 2.039171e-13 is less than options.ConstraintTolerance = 1.000000e-06
Thank you. matlab, code, fmincon, optimization, constraint MATLAB Answers — New Questions
Increase the size of MATLAB logo inside Simulink block
I want to increase the Matlab logo size inside the RL agent block and the size of 1/z inside the unit delay block but increasing the FOnt size is not working for them? what should I do?I want to increase the Matlab logo size inside the RL agent block and the size of 1/z inside the unit delay block but increasing the FOnt size is not working for them? what should I do? I want to increase the Matlab logo size inside the RL agent block and the size of 1/z inside the unit delay block but increasing the FOnt size is not working for them? what should I do? size increase, simulink blocks MATLAB Answers — New Questions
Memory usage of decomposition
Hello,
Consider linear systems Ax=b_i with A sparse and positive definite and several right hand sides b_i. In the experiments I have done, it is faster to use
dA = decomposition(A,’chol’,’upper’);
x_i = dAb_i; % repeat as needed
than the classical
R = chol(A);
x_i=R(R’b_i); % repeat as needed
But dA occupies much more memory than R
n = 1e5;d = 1e-5;rc = 1e-5;
A=sprand(n,n,d,rc);
A = A+A’+10*speye(n,n);
R = chol(A);
dA = decomposition(A,’chol’,’upper’);
memR = whos("R"); memR = memR.bytes;
memdA = whos("dA"); memdA = memdA.bytes;
fprintf(‘ R occupies %.1e bytes.ndA occupies %.1e bytesn’,memR,memdA)
Any idea of why? Any solution?
Thanks,
MarianoHello,
Consider linear systems Ax=b_i with A sparse and positive definite and several right hand sides b_i. In the experiments I have done, it is faster to use
dA = decomposition(A,’chol’,’upper’);
x_i = dAb_i; % repeat as needed
than the classical
R = chol(A);
x_i=R(R’b_i); % repeat as needed
But dA occupies much more memory than R
n = 1e5;d = 1e-5;rc = 1e-5;
A=sprand(n,n,d,rc);
A = A+A’+10*speye(n,n);
R = chol(A);
dA = decomposition(A,’chol’,’upper’);
memR = whos("R"); memR = memR.bytes;
memdA = whos("dA"); memdA = memdA.bytes;
fprintf(‘ R occupies %.1e bytes.ndA occupies %.1e bytesn’,memR,memdA)
Any idea of why? Any solution?
Thanks,
Mariano Hello,
Consider linear systems Ax=b_i with A sparse and positive definite and several right hand sides b_i. In the experiments I have done, it is faster to use
dA = decomposition(A,’chol’,’upper’);
x_i = dAb_i; % repeat as needed
than the classical
R = chol(A);
x_i=R(R’b_i); % repeat as needed
But dA occupies much more memory than R
n = 1e5;d = 1e-5;rc = 1e-5;
A=sprand(n,n,d,rc);
A = A+A’+10*speye(n,n);
R = chol(A);
dA = decomposition(A,’chol’,’upper’);
memR = whos("R"); memR = memR.bytes;
memdA = whos("dA"); memdA = memdA.bytes;
fprintf(‘ R occupies %.1e bytes.ndA occupies %.1e bytesn’,memR,memdA)
Any idea of why? Any solution?
Thanks,
Mariano linear systems, sparse matrix, decomposition, memory MATLAB Answers — New Questions
LaTeX interpreter with multiple strings or character vectors
I have a series of values in units of that I want to label on the x-axis using xticklabels(mylabels). I want to typeset the units using LaTeX command. Thus I specified latex as the interpretor for my tick labels using the commands:
ax=gca;
ax.TickLabelInterpreter=’Latex’;
The labels are displayed correctly when I set mylabels as cell array of character vectors as follows:
mylabels={‘$-2pi$’,’$-frac{3pi}{2}$’,’$-pi$’,’$-frac{pi}{2}$’,’0~~~~’,’$frac{pi}{2}$’,’$pi$’,’$frac{3pi}{2}$’,’$2pi$’};
However, when I specify mylabels as a cell array of strings, or a string array, or a character array as follows, the labels are not displayed on the x-axis.
mylabels=[‘$-2pi$’,’$-frac{3pi}{2}$’,’$-pi$’,’$-frac{pi}{2}$’,’0~~~~’,’$frac{pi}{2}$’,’$pi$’,… ‘$frac{3pi}{2}$’,’$2pi$’];
mylabels={"-2pi","-frac{3pi}{2}","-pi","-frac{pi}{2}","0~~~~", "frac{pi}{2}","pi","frac{3pi}{2}","2pi"};
mylabels=["-2pi","-frac{3pi}{2}","-pi","-frac{pi}{2}","0~~~~","frac{pi}{2}","pi","frac{3pi}{2}","2pi"];
I would like to understand what’s the problem here.
A complete MWE is given as follows:
figure;
xlabel("x")
ylabel("y")
xlim([-2*pi 2*pi])
xticks(-2*pi:pi/2:2*pi)
mylabels={‘$-2pi$’,’$-frac{3pi}{2}$’,’$-pi$’,’$-frac{pi}{2}$’,’0~~~~’,’$frac{pi}{2}$’,’$pi$’,’$frac{3pi}{2}$’,’$2pi$’};
xticklabels(mylabels)
ax=gca;
ax.TickLabelInterpreter=’Latex’;
Thank you very much in advance!I have a series of values in units of that I want to label on the x-axis using xticklabels(mylabels). I want to typeset the units using LaTeX command. Thus I specified latex as the interpretor for my tick labels using the commands:
ax=gca;
ax.TickLabelInterpreter=’Latex’;
The labels are displayed correctly when I set mylabels as cell array of character vectors as follows:
mylabels={‘$-2pi$’,’$-frac{3pi}{2}$’,’$-pi$’,’$-frac{pi}{2}$’,’0~~~~’,’$frac{pi}{2}$’,’$pi$’,’$frac{3pi}{2}$’,’$2pi$’};
However, when I specify mylabels as a cell array of strings, or a string array, or a character array as follows, the labels are not displayed on the x-axis.
mylabels=[‘$-2pi$’,’$-frac{3pi}{2}$’,’$-pi$’,’$-frac{pi}{2}$’,’0~~~~’,’$frac{pi}{2}$’,’$pi$’,… ‘$frac{3pi}{2}$’,’$2pi$’];
mylabels={"-2pi","-frac{3pi}{2}","-pi","-frac{pi}{2}","0~~~~", "frac{pi}{2}","pi","frac{3pi}{2}","2pi"};
mylabels=["-2pi","-frac{3pi}{2}","-pi","-frac{pi}{2}","0~~~~","frac{pi}{2}","pi","frac{3pi}{2}","2pi"];
I would like to understand what’s the problem here.
A complete MWE is given as follows:
figure;
xlabel("x")
ylabel("y")
xlim([-2*pi 2*pi])
xticks(-2*pi:pi/2:2*pi)
mylabels={‘$-2pi$’,’$-frac{3pi}{2}$’,’$-pi$’,’$-frac{pi}{2}$’,’0~~~~’,’$frac{pi}{2}$’,’$pi$’,’$frac{3pi}{2}$’,’$2pi$’};
xticklabels(mylabels)
ax=gca;
ax.TickLabelInterpreter=’Latex’;
Thank you very much in advance! I have a series of values in units of that I want to label on the x-axis using xticklabels(mylabels). I want to typeset the units using LaTeX command. Thus I specified latex as the interpretor for my tick labels using the commands:
ax=gca;
ax.TickLabelInterpreter=’Latex’;
The labels are displayed correctly when I set mylabels as cell array of character vectors as follows:
mylabels={‘$-2pi$’,’$-frac{3pi}{2}$’,’$-pi$’,’$-frac{pi}{2}$’,’0~~~~’,’$frac{pi}{2}$’,’$pi$’,’$frac{3pi}{2}$’,’$2pi$’};
However, when I specify mylabels as a cell array of strings, or a string array, or a character array as follows, the labels are not displayed on the x-axis.
mylabels=[‘$-2pi$’,’$-frac{3pi}{2}$’,’$-pi$’,’$-frac{pi}{2}$’,’0~~~~’,’$frac{pi}{2}$’,’$pi$’,… ‘$frac{3pi}{2}$’,’$2pi$’];
mylabels={"-2pi","-frac{3pi}{2}","-pi","-frac{pi}{2}","0~~~~", "frac{pi}{2}","pi","frac{3pi}{2}","2pi"};
mylabels=["-2pi","-frac{3pi}{2}","-pi","-frac{pi}{2}","0~~~~","frac{pi}{2}","pi","frac{3pi}{2}","2pi"];
I would like to understand what’s the problem here.
A complete MWE is given as follows:
figure;
xlabel("x")
ylabel("y")
xlim([-2*pi 2*pi])
xticks(-2*pi:pi/2:2*pi)
mylabels={‘$-2pi$’,’$-frac{3pi}{2}$’,’$-pi$’,’$-frac{pi}{2}$’,’0~~~~’,’$frac{pi}{2}$’,’$pi$’,’$frac{3pi}{2}$’,’$2pi$’};
xticklabels(mylabels)
ax=gca;
ax.TickLabelInterpreter=’Latex’;
Thank you very much in advance! plot, latex interpreter MATLAB Answers — New Questions
Needs solution for this Task from Matlab fundamentals course
Matlab fundamentals course:
7.Conditional Data Selection -> Logical Indexing(5/5) -> Visualizing Cricket StatisticsMatlab fundamentals course:
7.Conditional Data Selection -> Logical Indexing(5/5) -> Visualizing Cricket Statistics Matlab fundamentals course:
7.Conditional Data Selection -> Logical Indexing(5/5) -> Visualizing Cricket Statistics plot, text MATLAB Answers — New Questions
Time-Domain Responses of Multiple simulation with different model’s paramters
I need to compare the responses of various model’s parametrs , I’m using the multiple simulations panel in the simulink editor to run multiple simulations with varying values. I’m viewing the results in simulation manager, so I need to see as well the time-domain responses per multiple parameters, Is it possible to see/plot it in simulation manager?
Since I’m using "on-line" matlab version I can open Data InspectorI need to compare the responses of various model’s parametrs , I’m using the multiple simulations panel in the simulink editor to run multiple simulations with varying values. I’m viewing the results in simulation manager, so I need to see as well the time-domain responses per multiple parameters, Is it possible to see/plot it in simulation manager?
Since I’m using "on-line" matlab version I can open Data Inspector I need to compare the responses of various model’s parametrs , I’m using the multiple simulations panel in the simulink editor to run multiple simulations with varying values. I’m viewing the results in simulation manager, so I need to see as well the time-domain responses per multiple parameters, Is it possible to see/plot it in simulation manager?
Since I’m using "on-line" matlab version I can open Data Inspector multiple simulation plot results MATLAB Answers — New Questions