Month: June 2025
Gap in the plot
Hi,
I am given a contineuous water level data measured and measured cross section to calculate discharge by Manning equation. All these data were checked for gaps, and found contineuous. When running the following script the discharge having gaps, creats a jump which looks strange. Tried for several weeks to find it, but didn’t. Hope for your help.
%this script reads Cross and crocss-sections data from tributaries:
%Tzipori, Yiftachel, Tzvi, Oz, Mizra, Adashim, Taanach and Keini
%It 1. reads divers data 2. change them to be water level 3. calculate
%discharge.
%Discharge calculation requires:
%1. find the water level in the current time step 2. caculate discharge using manning
tic
clear all
close all
%%%%%%%%%%%% Part A: find water level of all sites%%%%%%%%%%%%%%%%%%%
% Get a list of all txt files in the current folder, or subfolders of it.
%Read discharge
lines1 = readlines("trib_names.txt");
trib_name=(categorical(lines1));
for i=1:length(trib_name)
trib1{i}=trib_name(i)
end
trib=string(trib1)+’level’; %for the case of water level;
cd ‘C:UsersuserDocumentsShulamitPhDMatlab_PhDHydrologyDischdivers’;
lvl=NaN(418907,16);%columns: longest diver data, rows/2= # of tributaries. each st. ha two columns: for date and data of stations
AllDivresfiles = natsortfiles(dir(‘*.txt’));
for k =1:size(AllDivresfiles,1)
% k=5%shut ‘end’ at the end of loop. Find thie in ‘kishon_catchment_discharge_calc_for1trib’
thisfilename1 = AllDivresfiles(k).name; %just the name
thisdata1 = load(thisfilename1); %load just this file
Lng_lvl(k)=length(thisdata1);
date1=x2mdate(thisdata1(:,1));
%plot(date1,thisdata1(:,2));ylabel(‘Level (cm)’)
num_days=length(unique(thisdata1(:,1)));
interval=720;%720 is the daily period of the time interval of data: 2 min. length(thisdata1(:,1))/(num_days*24);%Model has 1 hours intervals, so this is the interval obtained here. Obtain intervals according to 10 min intrval
baseP=min(thisdata1(:,2));%background pressure
curr_lvl1=(thisdata1(:,2)-baseP)/100;%units change to meter%for smoothing turn curr_lvl to curr_lvl1
curr_lvl=smoothdata(curr_lvl1,’movmean’,interval);
%curr_lvl=smoothdata(curr_lvl,’gaussian’,interval);
lvl(1:size(thisdata1,1),(2*k-1):2*k)=[date1 curr_lvl];%Removing diver’s bias (correct only forephemeral tributaries) and converting to m
lngt(k)=length(curr_lvl);
end
in0=find((lvl)==0);
lvl(in0)=NaN;
figure(‘Name’,’Adashim’);adash=lvl(:,1:2);plot(adash(:,1),adash(:,2));datetick;title=’Adashim lvl’;
figure(‘Name’,’Keini’);keini=lvl(:,3:4);plot(keini(:,1),keini(:,2));title=’Keini lvl’;datetick;
figure(‘Name’,’KishonMaale’);KishonMaale=lvl(:,5:6);plot(KishonMaale(:,1),KishonMaale(:,2));title=’KishonMaale lvl’;datetick
figure(‘Name’,’Mizra’);mizra=lvl(:,7:8);plot(mizra(:,1),mizra(:,2));title=’Mizra lvl’;datetick;
figure(‘Name’,’Oz’);oz=lvl(:,9:10);plot(oz(:,1),oz(:,2));title=’Oz lvl’;datetick;
figure(‘Name’,’Taanach’);taanach=lvl(:,11:12);plot(taanach(:,1),taanach(:,2));title=’Taanach lvl’;datetick;
figure(‘Name’,’Tzvi’);title=’Tzvi lvl’;tzvi=lvl(:,13:14);plot(tzvi(:,1),tzvi(:,2));datetick;
figure(‘Name’,’Yiftachel’);title=’Yiftachel lvl’;yiftachel=lvl(:,15:16);plot(yiftachel(:,1),yiftachel(:,2));title=’Yiftachel lvl’;datetick;
%%%%%%%%%%%% Part B: find cross section%%%%%%%%%%%%%%%%%%%
%Read cross sections. In most tributaries the divers are in the downstream
%All files with ‘1’ are upstrream and all with ‘2’ are downstreaצ. For example: OzUp=Oz1, OzDown=Oz2
trib=length(AllDivresfiles);
cd ‘C:UsersuserDocumentsShulamitPhDMatlab_PhDHydrologyDischcrossectionsDownstream’;
crs=NaN(max(lngt),5*trib);%columns: longest cross section data, rows-# of stations*5
AllCrossfiles = natsortfiles(dir(‘*.txt’));
min_for_slope1=NaN(trib,3);
%Collect all downstream crossection data together
for l = 1:length(AllCrossfiles)
%l=1 %shut ‘end’ at the end of loop
thisfilename2 = AllCrossfiles(l).name; %just the name
thisdata2 = load(thisfilename2); %load current file
crs(1:length(thisdata2),5*l-4:l*5)=thisdata2;
[MIN,I0]=min(thisdata2(:,3));%sea level elevation to have absolute elevation
min_for_slope1(l,:)=thisdata2(I0,1:3);%The slope is obtained by the slope bwtween two min of adjacent croo sections.
Lng(l)=length(thisdata2);
% figure(‘Name’,[char(trib_name(l)) ‘_crs_dn’])
% plot(crs(:,5*l-4),crs(:,5*l))
end
% adash1_crs=crs(:,4:5);keini1_crs=crs(:,9:10);mizra1_crs=crs(:,14:15);oz1_crs=crs(:,19:20);taanach1_crs=crs(:,24:25);tzvi1_crs=crs(:,29:30);yiftachel1_crs=crs(:,34:35);
% figure(11);plot(adash1_crs(:,1),adash1_crs(:,2));figure(22); plot(keini1_crs(:,1),keini1_crs(:,2));figure(33);plot(mizra1_crs(:,1),mizra1_crs(:,2));figure(44);plot(oz1_crs(:,1),oz1_crs(:,2));figure(55);plot(taanach1_crs(:,1),taanach1_crs(:,2));figure(66);plot(tzvi1_crs(:,1),tzvi1_crs(:,2));figure(77);plot(yiftachel1_crs(:,1),yiftachel1_crs(:,2));
%%%%% Part B1: Reading upstream for slope%%%%%%%%
min_for_slope2=NaN(trib,3);%coordinates (columns 1 and 2) and elevation (column3). of minimum in the cross sectioncolumns: longest diver data, rows/2= # of tributaries. each st. ha two columns: for date and data of stations
cd ‘C:UsersuserDocumentsShulamitPhDMatlab_PhDHydrologyDischcrossections’;
%min_for_slope=NaN(trib*2,2);%columns: longest cross section data, rows-# of stations
Allupstrmfiles = orderfields(dir(‘*.txt’));
for j = 1 : trib
upstrmName = Allupstrmfiles(j).name; %just the name; j or l
thisupstrm = load(upstrmName); %load just this file
[MIN1,I1]=min(thisupstrm(:,3));%Sea level to get absolute elevation
min_for_slope2(j,:)=(thisupstrm(I1,1:3));
% figure(‘Name’,[char(trib_name(j)) ‘_crs_up’])
% plot(thisupstrm(:,4),thisupstrm(:,3))
end
%%%%%%%%%%%%%%%%NEW 29052025%%%%%%%%%%%%%%%%%%%%%%%%%%%
all_lvl=NaN(max(lngt),trib);
discharge_all=NaN(418907,trib*2);%longest data
discharge=NaN(418907,2);
g=0;
f=0;
for t=1:trib
x=crs(1:Lng(t),5*t-4);
y=crs(1:Lng(t),5*t-3);
crsc=crs(1:Lng(t),5*t);
x0=x(1);y0=y(1);
distance1=((x-x0).^2+(y-y0).^2).^(1/2);%crs(1:Lng(t),5*t-1);
%Interpolation to create smoother discharge calculation
DF=abs(min(crsc(1:length(crsc)-1)-crsc(2:length(crsc))))/300;%Order of magnitude of distance difference and elveation are similar
basic_distance=distance1(1):DF:distance1(end);
distance11=1:(length(crsc));
distance=interp1(distance11,distance1,basic_distance);%to do interpolation to distance , since t is not a stright line
smth_crs=interp1(distance1,crsc,distance);
% smth_x=interp1(distance1,x,distance);
% smth_y=interp1(distance1,y,distance);
for m=1:Lng_lvl(t)%m=233648
if isnan(lvl(m,2*t))
discharge(m,1:2)=[lvl(m,2*t-1) NaN];
f=f+1;
continue
end
[M lvl_ind1]=min(abs(lvl(m,2*t)-smth_crs));%Find current water level in lvl and the current cross section
if smth_crs(lvl_ind1)==min(smth_crs)
discharge(m,1:2)=[lvl(m,2*t-1) 0];
g=g+1;
continue
end
lvl_ind2=find(smth_crs<=smth_crs(lvl_ind1));
distance2=distance(lvl_ind2);smth_crs2=smth_crs(lvl_ind2);
P1=((distance2(2:end)-distance2(1:end-1)).^2+(smth_crs2(2:end)-smth_crs2(1:end-1)).^2).^(1/2);
% lvl_ind2=find(smth_crs<=smth_crs(lvl_ind1));
% lvl_ind22=crsc<=min(crsc);
% crsc_lvl=crsc(lvl_ind22);
% x_lvl=x(lvl_ind22);%Due to wetted perimeter.
% y_lvl=y(lvl_ind22);%Due to wetted perimeter.
% % smth_x_lvl=smth_x(lvl_ind2);%Due to wetted perimeter.
% % smth_y_lvl=smth_y(lvl_ind2);%Due to wetted perimeter.
% smth_crs_lvl=smth_crs(lvl_ind2);%Due to wetted perimeter.
%Wetted perimeter:
% P1=((x_lvl(2:end)-x_lvl(1:end-1)).^2+(y_lvl(2:end)-y_lvl(1:end-1)).^2+(crsc_lvl(2:end)-crsc_lvl(1:end-1)).^2).^(1/2);
P(m)=sum(P1);
if isnan(P(m))
discharge(m,1:2)=[lvl(m,2*t-1) 0];
q=q+1;
continue
end
%Slope
dx = min_for_slope2(t,1) – min_for_slope1(t,1);
dy = min_for_slope2(t,2) – min_for_slope1(t,2);
dz(t) = min_for_slope2(t,3) – min_for_slope1(t,3);
distance3D = sqrt(dx^2 + dy^2 + dz(t)^2);
S(t) = abs(dz(t)) / distance3D;
% S(t)=min_for_slope2(t,3)-min_for_slope1(t,3)/(min_for_slope2(t,1)-min_for_slope1(t,1))^2+(min_for_slope2(t,2)-min_for_slope1(t,2))^2+…
% (min_for_slope2(t,3)-min_for_slope1(t,3))^2;%Slope. Constant for crossection
%Area
A(m) = trapz(distance(lvl_ind2), smth_crs(lvl_ind1) – smth_crs(lvl_ind2)); % assumes smth_crs is bed elevation
%A(m)=trapz(distance-smth_crs);
R(m)=A(m)/P(m);%Hydraulic radius;
%Manning
%Effect of water level on n of Manning:
if smth_crs(lvl_ind1) < 0.3
N = 0.1;
elseif and(smth_crs(lvl_ind1) >= 0.3, smth_crs(lvl_ind1) < 0.7)
N = 0.06;
else
N = 0.03;
end
discharge1=(A(m)*(1/N)*R(m)^(2/3))*S(t)^(1/2);
discharge(m,1:2)=[lvl(m,2*t-1) discharge1];
end%end ‘for m=…’
% figure(‘Name’,[char(trib_name(t)) ‘_smth_crs’])
% plot(smth_crs)
discharge_all(1:size(discharge,1),2*t-1:2*t)=discharge;
% [discharge2,ia,~] = unique(discharge1(:,2));
% discharge=[lvl(ia,2*t-1) discharge2];
% discharge_all(1:size(discharge,1),2*t-1:2*t)=discharge;
% plot(date1,discharge_all);
n=t;
discharge_all(1:length(discharge),2*n-1:2*n)=discharge;
% figure(n)
% plot(discharge_all(1:Lng_lvl(n),2*n-1),discharge_all(1:Lng_lvl(n),2*n))
% title=trib_name(n);
% ylabel(‘Q (m^3/s)’)
% datetick
figure(‘name’,char(trib_name(t)))
plot(lvl(:,2*t-1),discharge_all(:,2*t),’.’)
%title(names(t));
ylabel(‘Q (m^3/s)’)
datetick
end
%end %end for t=, m=…
discharge_all_smth=discharge_all;
filename = ‘C:UsersuserDocumentsShulamitPhDMatlab_PhDHydrologyDischdischarge_all_smth.mat’;
save( filename, ‘discharge_all_smth’ );
tocHi,
I am given a contineuous water level data measured and measured cross section to calculate discharge by Manning equation. All these data were checked for gaps, and found contineuous. When running the following script the discharge having gaps, creats a jump which looks strange. Tried for several weeks to find it, but didn’t. Hope for your help.
%this script reads Cross and crocss-sections data from tributaries:
%Tzipori, Yiftachel, Tzvi, Oz, Mizra, Adashim, Taanach and Keini
%It 1. reads divers data 2. change them to be water level 3. calculate
%discharge.
%Discharge calculation requires:
%1. find the water level in the current time step 2. caculate discharge using manning
tic
clear all
close all
%%%%%%%%%%%% Part A: find water level of all sites%%%%%%%%%%%%%%%%%%%
% Get a list of all txt files in the current folder, or subfolders of it.
%Read discharge
lines1 = readlines("trib_names.txt");
trib_name=(categorical(lines1));
for i=1:length(trib_name)
trib1{i}=trib_name(i)
end
trib=string(trib1)+’level’; %for the case of water level;
cd ‘C:UsersuserDocumentsShulamitPhDMatlab_PhDHydrologyDischdivers’;
lvl=NaN(418907,16);%columns: longest diver data, rows/2= # of tributaries. each st. ha two columns: for date and data of stations
AllDivresfiles = natsortfiles(dir(‘*.txt’));
for k =1:size(AllDivresfiles,1)
% k=5%shut ‘end’ at the end of loop. Find thie in ‘kishon_catchment_discharge_calc_for1trib’
thisfilename1 = AllDivresfiles(k).name; %just the name
thisdata1 = load(thisfilename1); %load just this file
Lng_lvl(k)=length(thisdata1);
date1=x2mdate(thisdata1(:,1));
%plot(date1,thisdata1(:,2));ylabel(‘Level (cm)’)
num_days=length(unique(thisdata1(:,1)));
interval=720;%720 is the daily period of the time interval of data: 2 min. length(thisdata1(:,1))/(num_days*24);%Model has 1 hours intervals, so this is the interval obtained here. Obtain intervals according to 10 min intrval
baseP=min(thisdata1(:,2));%background pressure
curr_lvl1=(thisdata1(:,2)-baseP)/100;%units change to meter%for smoothing turn curr_lvl to curr_lvl1
curr_lvl=smoothdata(curr_lvl1,’movmean’,interval);
%curr_lvl=smoothdata(curr_lvl,’gaussian’,interval);
lvl(1:size(thisdata1,1),(2*k-1):2*k)=[date1 curr_lvl];%Removing diver’s bias (correct only forephemeral tributaries) and converting to m
lngt(k)=length(curr_lvl);
end
in0=find((lvl)==0);
lvl(in0)=NaN;
figure(‘Name’,’Adashim’);adash=lvl(:,1:2);plot(adash(:,1),adash(:,2));datetick;title=’Adashim lvl’;
figure(‘Name’,’Keini’);keini=lvl(:,3:4);plot(keini(:,1),keini(:,2));title=’Keini lvl’;datetick;
figure(‘Name’,’KishonMaale’);KishonMaale=lvl(:,5:6);plot(KishonMaale(:,1),KishonMaale(:,2));title=’KishonMaale lvl’;datetick
figure(‘Name’,’Mizra’);mizra=lvl(:,7:8);plot(mizra(:,1),mizra(:,2));title=’Mizra lvl’;datetick;
figure(‘Name’,’Oz’);oz=lvl(:,9:10);plot(oz(:,1),oz(:,2));title=’Oz lvl’;datetick;
figure(‘Name’,’Taanach’);taanach=lvl(:,11:12);plot(taanach(:,1),taanach(:,2));title=’Taanach lvl’;datetick;
figure(‘Name’,’Tzvi’);title=’Tzvi lvl’;tzvi=lvl(:,13:14);plot(tzvi(:,1),tzvi(:,2));datetick;
figure(‘Name’,’Yiftachel’);title=’Yiftachel lvl’;yiftachel=lvl(:,15:16);plot(yiftachel(:,1),yiftachel(:,2));title=’Yiftachel lvl’;datetick;
%%%%%%%%%%%% Part B: find cross section%%%%%%%%%%%%%%%%%%%
%Read cross sections. In most tributaries the divers are in the downstream
%All files with ‘1’ are upstrream and all with ‘2’ are downstreaצ. For example: OzUp=Oz1, OzDown=Oz2
trib=length(AllDivresfiles);
cd ‘C:UsersuserDocumentsShulamitPhDMatlab_PhDHydrologyDischcrossectionsDownstream’;
crs=NaN(max(lngt),5*trib);%columns: longest cross section data, rows-# of stations*5
AllCrossfiles = natsortfiles(dir(‘*.txt’));
min_for_slope1=NaN(trib,3);
%Collect all downstream crossection data together
for l = 1:length(AllCrossfiles)
%l=1 %shut ‘end’ at the end of loop
thisfilename2 = AllCrossfiles(l).name; %just the name
thisdata2 = load(thisfilename2); %load current file
crs(1:length(thisdata2),5*l-4:l*5)=thisdata2;
[MIN,I0]=min(thisdata2(:,3));%sea level elevation to have absolute elevation
min_for_slope1(l,:)=thisdata2(I0,1:3);%The slope is obtained by the slope bwtween two min of adjacent croo sections.
Lng(l)=length(thisdata2);
% figure(‘Name’,[char(trib_name(l)) ‘_crs_dn’])
% plot(crs(:,5*l-4),crs(:,5*l))
end
% adash1_crs=crs(:,4:5);keini1_crs=crs(:,9:10);mizra1_crs=crs(:,14:15);oz1_crs=crs(:,19:20);taanach1_crs=crs(:,24:25);tzvi1_crs=crs(:,29:30);yiftachel1_crs=crs(:,34:35);
% figure(11);plot(adash1_crs(:,1),adash1_crs(:,2));figure(22); plot(keini1_crs(:,1),keini1_crs(:,2));figure(33);plot(mizra1_crs(:,1),mizra1_crs(:,2));figure(44);plot(oz1_crs(:,1),oz1_crs(:,2));figure(55);plot(taanach1_crs(:,1),taanach1_crs(:,2));figure(66);plot(tzvi1_crs(:,1),tzvi1_crs(:,2));figure(77);plot(yiftachel1_crs(:,1),yiftachel1_crs(:,2));
%%%%% Part B1: Reading upstream for slope%%%%%%%%
min_for_slope2=NaN(trib,3);%coordinates (columns 1 and 2) and elevation (column3). of minimum in the cross sectioncolumns: longest diver data, rows/2= # of tributaries. each st. ha two columns: for date and data of stations
cd ‘C:UsersuserDocumentsShulamitPhDMatlab_PhDHydrologyDischcrossections’;
%min_for_slope=NaN(trib*2,2);%columns: longest cross section data, rows-# of stations
Allupstrmfiles = orderfields(dir(‘*.txt’));
for j = 1 : trib
upstrmName = Allupstrmfiles(j).name; %just the name; j or l
thisupstrm = load(upstrmName); %load just this file
[MIN1,I1]=min(thisupstrm(:,3));%Sea level to get absolute elevation
min_for_slope2(j,:)=(thisupstrm(I1,1:3));
% figure(‘Name’,[char(trib_name(j)) ‘_crs_up’])
% plot(thisupstrm(:,4),thisupstrm(:,3))
end
%%%%%%%%%%%%%%%%NEW 29052025%%%%%%%%%%%%%%%%%%%%%%%%%%%
all_lvl=NaN(max(lngt),trib);
discharge_all=NaN(418907,trib*2);%longest data
discharge=NaN(418907,2);
g=0;
f=0;
for t=1:trib
x=crs(1:Lng(t),5*t-4);
y=crs(1:Lng(t),5*t-3);
crsc=crs(1:Lng(t),5*t);
x0=x(1);y0=y(1);
distance1=((x-x0).^2+(y-y0).^2).^(1/2);%crs(1:Lng(t),5*t-1);
%Interpolation to create smoother discharge calculation
DF=abs(min(crsc(1:length(crsc)-1)-crsc(2:length(crsc))))/300;%Order of magnitude of distance difference and elveation are similar
basic_distance=distance1(1):DF:distance1(end);
distance11=1:(length(crsc));
distance=interp1(distance11,distance1,basic_distance);%to do interpolation to distance , since t is not a stright line
smth_crs=interp1(distance1,crsc,distance);
% smth_x=interp1(distance1,x,distance);
% smth_y=interp1(distance1,y,distance);
for m=1:Lng_lvl(t)%m=233648
if isnan(lvl(m,2*t))
discharge(m,1:2)=[lvl(m,2*t-1) NaN];
f=f+1;
continue
end
[M lvl_ind1]=min(abs(lvl(m,2*t)-smth_crs));%Find current water level in lvl and the current cross section
if smth_crs(lvl_ind1)==min(smth_crs)
discharge(m,1:2)=[lvl(m,2*t-1) 0];
g=g+1;
continue
end
lvl_ind2=find(smth_crs<=smth_crs(lvl_ind1));
distance2=distance(lvl_ind2);smth_crs2=smth_crs(lvl_ind2);
P1=((distance2(2:end)-distance2(1:end-1)).^2+(smth_crs2(2:end)-smth_crs2(1:end-1)).^2).^(1/2);
% lvl_ind2=find(smth_crs<=smth_crs(lvl_ind1));
% lvl_ind22=crsc<=min(crsc);
% crsc_lvl=crsc(lvl_ind22);
% x_lvl=x(lvl_ind22);%Due to wetted perimeter.
% y_lvl=y(lvl_ind22);%Due to wetted perimeter.
% % smth_x_lvl=smth_x(lvl_ind2);%Due to wetted perimeter.
% % smth_y_lvl=smth_y(lvl_ind2);%Due to wetted perimeter.
% smth_crs_lvl=smth_crs(lvl_ind2);%Due to wetted perimeter.
%Wetted perimeter:
% P1=((x_lvl(2:end)-x_lvl(1:end-1)).^2+(y_lvl(2:end)-y_lvl(1:end-1)).^2+(crsc_lvl(2:end)-crsc_lvl(1:end-1)).^2).^(1/2);
P(m)=sum(P1);
if isnan(P(m))
discharge(m,1:2)=[lvl(m,2*t-1) 0];
q=q+1;
continue
end
%Slope
dx = min_for_slope2(t,1) – min_for_slope1(t,1);
dy = min_for_slope2(t,2) – min_for_slope1(t,2);
dz(t) = min_for_slope2(t,3) – min_for_slope1(t,3);
distance3D = sqrt(dx^2 + dy^2 + dz(t)^2);
S(t) = abs(dz(t)) / distance3D;
% S(t)=min_for_slope2(t,3)-min_for_slope1(t,3)/(min_for_slope2(t,1)-min_for_slope1(t,1))^2+(min_for_slope2(t,2)-min_for_slope1(t,2))^2+…
% (min_for_slope2(t,3)-min_for_slope1(t,3))^2;%Slope. Constant for crossection
%Area
A(m) = trapz(distance(lvl_ind2), smth_crs(lvl_ind1) – smth_crs(lvl_ind2)); % assumes smth_crs is bed elevation
%A(m)=trapz(distance-smth_crs);
R(m)=A(m)/P(m);%Hydraulic radius;
%Manning
%Effect of water level on n of Manning:
if smth_crs(lvl_ind1) < 0.3
N = 0.1;
elseif and(smth_crs(lvl_ind1) >= 0.3, smth_crs(lvl_ind1) < 0.7)
N = 0.06;
else
N = 0.03;
end
discharge1=(A(m)*(1/N)*R(m)^(2/3))*S(t)^(1/2);
discharge(m,1:2)=[lvl(m,2*t-1) discharge1];
end%end ‘for m=…’
% figure(‘Name’,[char(trib_name(t)) ‘_smth_crs’])
% plot(smth_crs)
discharge_all(1:size(discharge,1),2*t-1:2*t)=discharge;
% [discharge2,ia,~] = unique(discharge1(:,2));
% discharge=[lvl(ia,2*t-1) discharge2];
% discharge_all(1:size(discharge,1),2*t-1:2*t)=discharge;
% plot(date1,discharge_all);
n=t;
discharge_all(1:length(discharge),2*n-1:2*n)=discharge;
% figure(n)
% plot(discharge_all(1:Lng_lvl(n),2*n-1),discharge_all(1:Lng_lvl(n),2*n))
% title=trib_name(n);
% ylabel(‘Q (m^3/s)’)
% datetick
figure(‘name’,char(trib_name(t)))
plot(lvl(:,2*t-1),discharge_all(:,2*t),’.’)
%title(names(t));
ylabel(‘Q (m^3/s)’)
datetick
end
%end %end for t=, m=…
discharge_all_smth=discharge_all;
filename = ‘C:UsersuserDocumentsShulamitPhDMatlab_PhDHydrologyDischdischarge_all_smth.mat’;
save( filename, ‘discharge_all_smth’ );
toc Hi,
I am given a contineuous water level data measured and measured cross section to calculate discharge by Manning equation. All these data were checked for gaps, and found contineuous. When running the following script the discharge having gaps, creats a jump which looks strange. Tried for several weeks to find it, but didn’t. Hope for your help.
%this script reads Cross and crocss-sections data from tributaries:
%Tzipori, Yiftachel, Tzvi, Oz, Mizra, Adashim, Taanach and Keini
%It 1. reads divers data 2. change them to be water level 3. calculate
%discharge.
%Discharge calculation requires:
%1. find the water level in the current time step 2. caculate discharge using manning
tic
clear all
close all
%%%%%%%%%%%% Part A: find water level of all sites%%%%%%%%%%%%%%%%%%%
% Get a list of all txt files in the current folder, or subfolders of it.
%Read discharge
lines1 = readlines("trib_names.txt");
trib_name=(categorical(lines1));
for i=1:length(trib_name)
trib1{i}=trib_name(i)
end
trib=string(trib1)+’level’; %for the case of water level;
cd ‘C:UsersuserDocumentsShulamitPhDMatlab_PhDHydrologyDischdivers’;
lvl=NaN(418907,16);%columns: longest diver data, rows/2= # of tributaries. each st. ha two columns: for date and data of stations
AllDivresfiles = natsortfiles(dir(‘*.txt’));
for k =1:size(AllDivresfiles,1)
% k=5%shut ‘end’ at the end of loop. Find thie in ‘kishon_catchment_discharge_calc_for1trib’
thisfilename1 = AllDivresfiles(k).name; %just the name
thisdata1 = load(thisfilename1); %load just this file
Lng_lvl(k)=length(thisdata1);
date1=x2mdate(thisdata1(:,1));
%plot(date1,thisdata1(:,2));ylabel(‘Level (cm)’)
num_days=length(unique(thisdata1(:,1)));
interval=720;%720 is the daily period of the time interval of data: 2 min. length(thisdata1(:,1))/(num_days*24);%Model has 1 hours intervals, so this is the interval obtained here. Obtain intervals according to 10 min intrval
baseP=min(thisdata1(:,2));%background pressure
curr_lvl1=(thisdata1(:,2)-baseP)/100;%units change to meter%for smoothing turn curr_lvl to curr_lvl1
curr_lvl=smoothdata(curr_lvl1,’movmean’,interval);
%curr_lvl=smoothdata(curr_lvl,’gaussian’,interval);
lvl(1:size(thisdata1,1),(2*k-1):2*k)=[date1 curr_lvl];%Removing diver’s bias (correct only forephemeral tributaries) and converting to m
lngt(k)=length(curr_lvl);
end
in0=find((lvl)==0);
lvl(in0)=NaN;
figure(‘Name’,’Adashim’);adash=lvl(:,1:2);plot(adash(:,1),adash(:,2));datetick;title=’Adashim lvl’;
figure(‘Name’,’Keini’);keini=lvl(:,3:4);plot(keini(:,1),keini(:,2));title=’Keini lvl’;datetick;
figure(‘Name’,’KishonMaale’);KishonMaale=lvl(:,5:6);plot(KishonMaale(:,1),KishonMaale(:,2));title=’KishonMaale lvl’;datetick
figure(‘Name’,’Mizra’);mizra=lvl(:,7:8);plot(mizra(:,1),mizra(:,2));title=’Mizra lvl’;datetick;
figure(‘Name’,’Oz’);oz=lvl(:,9:10);plot(oz(:,1),oz(:,2));title=’Oz lvl’;datetick;
figure(‘Name’,’Taanach’);taanach=lvl(:,11:12);plot(taanach(:,1),taanach(:,2));title=’Taanach lvl’;datetick;
figure(‘Name’,’Tzvi’);title=’Tzvi lvl’;tzvi=lvl(:,13:14);plot(tzvi(:,1),tzvi(:,2));datetick;
figure(‘Name’,’Yiftachel’);title=’Yiftachel lvl’;yiftachel=lvl(:,15:16);plot(yiftachel(:,1),yiftachel(:,2));title=’Yiftachel lvl’;datetick;
%%%%%%%%%%%% Part B: find cross section%%%%%%%%%%%%%%%%%%%
%Read cross sections. In most tributaries the divers are in the downstream
%All files with ‘1’ are upstrream and all with ‘2’ are downstreaצ. For example: OzUp=Oz1, OzDown=Oz2
trib=length(AllDivresfiles);
cd ‘C:UsersuserDocumentsShulamitPhDMatlab_PhDHydrologyDischcrossectionsDownstream’;
crs=NaN(max(lngt),5*trib);%columns: longest cross section data, rows-# of stations*5
AllCrossfiles = natsortfiles(dir(‘*.txt’));
min_for_slope1=NaN(trib,3);
%Collect all downstream crossection data together
for l = 1:length(AllCrossfiles)
%l=1 %shut ‘end’ at the end of loop
thisfilename2 = AllCrossfiles(l).name; %just the name
thisdata2 = load(thisfilename2); %load current file
crs(1:length(thisdata2),5*l-4:l*5)=thisdata2;
[MIN,I0]=min(thisdata2(:,3));%sea level elevation to have absolute elevation
min_for_slope1(l,:)=thisdata2(I0,1:3);%The slope is obtained by the slope bwtween two min of adjacent croo sections.
Lng(l)=length(thisdata2);
% figure(‘Name’,[char(trib_name(l)) ‘_crs_dn’])
% plot(crs(:,5*l-4),crs(:,5*l))
end
% adash1_crs=crs(:,4:5);keini1_crs=crs(:,9:10);mizra1_crs=crs(:,14:15);oz1_crs=crs(:,19:20);taanach1_crs=crs(:,24:25);tzvi1_crs=crs(:,29:30);yiftachel1_crs=crs(:,34:35);
% figure(11);plot(adash1_crs(:,1),adash1_crs(:,2));figure(22); plot(keini1_crs(:,1),keini1_crs(:,2));figure(33);plot(mizra1_crs(:,1),mizra1_crs(:,2));figure(44);plot(oz1_crs(:,1),oz1_crs(:,2));figure(55);plot(taanach1_crs(:,1),taanach1_crs(:,2));figure(66);plot(tzvi1_crs(:,1),tzvi1_crs(:,2));figure(77);plot(yiftachel1_crs(:,1),yiftachel1_crs(:,2));
%%%%% Part B1: Reading upstream for slope%%%%%%%%
min_for_slope2=NaN(trib,3);%coordinates (columns 1 and 2) and elevation (column3). of minimum in the cross sectioncolumns: longest diver data, rows/2= # of tributaries. each st. ha two columns: for date and data of stations
cd ‘C:UsersuserDocumentsShulamitPhDMatlab_PhDHydrologyDischcrossections’;
%min_for_slope=NaN(trib*2,2);%columns: longest cross section data, rows-# of stations
Allupstrmfiles = orderfields(dir(‘*.txt’));
for j = 1 : trib
upstrmName = Allupstrmfiles(j).name; %just the name; j or l
thisupstrm = load(upstrmName); %load just this file
[MIN1,I1]=min(thisupstrm(:,3));%Sea level to get absolute elevation
min_for_slope2(j,:)=(thisupstrm(I1,1:3));
% figure(‘Name’,[char(trib_name(j)) ‘_crs_up’])
% plot(thisupstrm(:,4),thisupstrm(:,3))
end
%%%%%%%%%%%%%%%%NEW 29052025%%%%%%%%%%%%%%%%%%%%%%%%%%%
all_lvl=NaN(max(lngt),trib);
discharge_all=NaN(418907,trib*2);%longest data
discharge=NaN(418907,2);
g=0;
f=0;
for t=1:trib
x=crs(1:Lng(t),5*t-4);
y=crs(1:Lng(t),5*t-3);
crsc=crs(1:Lng(t),5*t);
x0=x(1);y0=y(1);
distance1=((x-x0).^2+(y-y0).^2).^(1/2);%crs(1:Lng(t),5*t-1);
%Interpolation to create smoother discharge calculation
DF=abs(min(crsc(1:length(crsc)-1)-crsc(2:length(crsc))))/300;%Order of magnitude of distance difference and elveation are similar
basic_distance=distance1(1):DF:distance1(end);
distance11=1:(length(crsc));
distance=interp1(distance11,distance1,basic_distance);%to do interpolation to distance , since t is not a stright line
smth_crs=interp1(distance1,crsc,distance);
% smth_x=interp1(distance1,x,distance);
% smth_y=interp1(distance1,y,distance);
for m=1:Lng_lvl(t)%m=233648
if isnan(lvl(m,2*t))
discharge(m,1:2)=[lvl(m,2*t-1) NaN];
f=f+1;
continue
end
[M lvl_ind1]=min(abs(lvl(m,2*t)-smth_crs));%Find current water level in lvl and the current cross section
if smth_crs(lvl_ind1)==min(smth_crs)
discharge(m,1:2)=[lvl(m,2*t-1) 0];
g=g+1;
continue
end
lvl_ind2=find(smth_crs<=smth_crs(lvl_ind1));
distance2=distance(lvl_ind2);smth_crs2=smth_crs(lvl_ind2);
P1=((distance2(2:end)-distance2(1:end-1)).^2+(smth_crs2(2:end)-smth_crs2(1:end-1)).^2).^(1/2);
% lvl_ind2=find(smth_crs<=smth_crs(lvl_ind1));
% lvl_ind22=crsc<=min(crsc);
% crsc_lvl=crsc(lvl_ind22);
% x_lvl=x(lvl_ind22);%Due to wetted perimeter.
% y_lvl=y(lvl_ind22);%Due to wetted perimeter.
% % smth_x_lvl=smth_x(lvl_ind2);%Due to wetted perimeter.
% % smth_y_lvl=smth_y(lvl_ind2);%Due to wetted perimeter.
% smth_crs_lvl=smth_crs(lvl_ind2);%Due to wetted perimeter.
%Wetted perimeter:
% P1=((x_lvl(2:end)-x_lvl(1:end-1)).^2+(y_lvl(2:end)-y_lvl(1:end-1)).^2+(crsc_lvl(2:end)-crsc_lvl(1:end-1)).^2).^(1/2);
P(m)=sum(P1);
if isnan(P(m))
discharge(m,1:2)=[lvl(m,2*t-1) 0];
q=q+1;
continue
end
%Slope
dx = min_for_slope2(t,1) – min_for_slope1(t,1);
dy = min_for_slope2(t,2) – min_for_slope1(t,2);
dz(t) = min_for_slope2(t,3) – min_for_slope1(t,3);
distance3D = sqrt(dx^2 + dy^2 + dz(t)^2);
S(t) = abs(dz(t)) / distance3D;
% S(t)=min_for_slope2(t,3)-min_for_slope1(t,3)/(min_for_slope2(t,1)-min_for_slope1(t,1))^2+(min_for_slope2(t,2)-min_for_slope1(t,2))^2+…
% (min_for_slope2(t,3)-min_for_slope1(t,3))^2;%Slope. Constant for crossection
%Area
A(m) = trapz(distance(lvl_ind2), smth_crs(lvl_ind1) – smth_crs(lvl_ind2)); % assumes smth_crs is bed elevation
%A(m)=trapz(distance-smth_crs);
R(m)=A(m)/P(m);%Hydraulic radius;
%Manning
%Effect of water level on n of Manning:
if smth_crs(lvl_ind1) < 0.3
N = 0.1;
elseif and(smth_crs(lvl_ind1) >= 0.3, smth_crs(lvl_ind1) < 0.7)
N = 0.06;
else
N = 0.03;
end
discharge1=(A(m)*(1/N)*R(m)^(2/3))*S(t)^(1/2);
discharge(m,1:2)=[lvl(m,2*t-1) discharge1];
end%end ‘for m=…’
% figure(‘Name’,[char(trib_name(t)) ‘_smth_crs’])
% plot(smth_crs)
discharge_all(1:size(discharge,1),2*t-1:2*t)=discharge;
% [discharge2,ia,~] = unique(discharge1(:,2));
% discharge=[lvl(ia,2*t-1) discharge2];
% discharge_all(1:size(discharge,1),2*t-1:2*t)=discharge;
% plot(date1,discharge_all);
n=t;
discharge_all(1:length(discharge),2*n-1:2*n)=discharge;
% figure(n)
% plot(discharge_all(1:Lng_lvl(n),2*n-1),discharge_all(1:Lng_lvl(n),2*n))
% title=trib_name(n);
% ylabel(‘Q (m^3/s)’)
% datetick
figure(‘name’,char(trib_name(t)))
plot(lvl(:,2*t-1),discharge_all(:,2*t),’.’)
%title(names(t));
ylabel(‘Q (m^3/s)’)
datetick
end
%end %end for t=, m=…
discharge_all_smth=discharge_all;
filename = ‘C:UsersuserDocumentsShulamitPhDMatlab_PhDHydrologyDischdischarge_all_smth.mat’;
save( filename, ‘discharge_all_smth’ );
toc hydrology manning water level gap in discharge MATLAB Answers — New Questions
Guideline for implementing PID and saturation
I have the following model where I have as a setpoint a step input with constant value 10 and stepme 0 and used initially a step input of value 600 in order to approximate an impulse; which are now the PID and saturation block guidelines in order to successfully track the setpoint (R=10)? How can I achieve an oscillating behaviour around the setpoint?I have the following model where I have as a setpoint a step input with constant value 10 and stepme 0 and used initially a step input of value 600 in order to approximate an impulse; which are now the PID and saturation block guidelines in order to successfully track the setpoint (R=10)? How can I achieve an oscillating behaviour around the setpoint? I have the following model where I have as a setpoint a step input with constant value 10 and stepme 0 and used initially a step input of value 600 in order to approximate an impulse; which are now the PID and saturation block guidelines in order to successfully track the setpoint (R=10)? How can I achieve an oscillating behaviour around the setpoint? pid, saturation MATLAB Answers — New Questions
Mailbox Import-Export Graph APIs Leave No Audit Trail
Use the Import-Export Graph API to Copy Data from Mailboxes Without a Trace
A recent LinkedIn post by a security practitioner set some alarm bells ringing when it disclosed that the Graph Mailbox Import-Export APIs processed mailbox content without creating audit events to track activity. Given that a) any operation that can exfiltrate mailbox data could be a highly prized tool for attackers and b) the extensive auditing capabilities built into Microsoft 365, this oversight is more than surprising.
What’s poignant about the situation is that Microsoft released the Mailbox Import-Export Graph APIs as part of their campaign to eliminate Exchange Web Services (EWS). EWS is deemed to be insecure and was used to exfiltrate mailbox data from many sensitive executive mailboxes in the Midnight Blizzard attack on Microsoft’s own tenant in March 2024.
Since then, Microsoft has been on a campaign to eradicate EWS from Microsoft 365 as quickly as practicable. The deadline for all apps to stop using EWS is October 2026, and Microsoft plans to eliminate EWS from first-party apps by October 2025, with recent moves to lay the path for Exchange Online and Teams to stop using EWS to share free-busy information and other data.
To be fair to Microsoft, the Mailbox Import-Export Graph API is in preview and beta software usually has a few holes to fill before it can become generally available. On the other hand, Microsoft launched the API in January 2025 and you’d imagine that someone in the development team would have noticed by now. The good news is that Microsoft has acknowledged the issue. I don’t imagine that it will take them long to begin generating audit events for import and export activities.
For an independent take on using the Mailbox Import-Export Graph API, I recommend reading the articles published by MVP Glen Scales.
Testing Auditing of Permanent Removals
Another step in the EWS removal process came with the launch of APIs to permanently remove mailbox items (including calendar items, contacts, and events). Given the issue reported above, I wanted to check if Exchange Online generated audit events for the permanent removal APIs. It’s not inconceivable that an attacker would seek to remove some items from a mailbox, and so much the better if they can do it without detection.
I processed some permanent deletions for mailbox objects and then ran an audit search for hard deletions (which is what these events are).
[array]$Records = Search-UnifiedAuditLog -StartDate '29-May-2025 10:00' -EndDate (Get-Date) -Formatted -SessionCommand ReturnLargeSet -ResultSize 5000 -Operations 'HardDelete'
Audit events for the permanent deletions duly turned up.
Permanent Removals of Calendar Events
I then processed a permanent deletion of a calendar event by finding some events in my own calendar, selecting one, and deleting it:
[array]$Events = Get-MgUserCalendarView -UserId $userId -Startdatetime "2025-01-01T19:00:00-08:00" -Enddatetime "2025-02-20T19:00:00-08:00" $Event = $Events[1] $Uri = $("https://graph.microsoft.com/v1.0/users/{0}/Events/{1}/permanentdelete" -f $UserId, $Event.Id) Invoke-MgGraphRequest -Uri $Uri -Method Post
Again, Exchange Online captured a hard delete audit event for the deletion (Figure 1)

Deleting different types of mailbox items permanently generates audit events. I expected this to be the case because these are not new APIs. Instead, Microsoft extended existing APIs to support permanent deletion, and the extension picked up the existing auditing mechanism.
Auditing is Critical
Some might consider the inclusion of auditing to be a small point when an API is in beta. It’s an arguable point, but the counter is that attackers don’t care if an API that can do a job for them is a beta or production API. All they worry about is the outcome, which could be a bunch of data noiselessly moved out of a tenant.
Of course, the tenant must be compromised beforehand, but evidence exists of cases where attackers penetrated a tenant and waited months before seizing an opportunity to do damage. A beta API that doesn’t generate audit records sounds like just the kind of tool attackers might like to use.
Need some assistance to write and manage PowerShell scripts for Microsoft 365? Get a copy of the Automating Microsoft 365 with PowerShell eBook, available standalone or as part of the Office 365 for IT Pros eBook bundle.
PIL Simulation Warning: “Top model does not contain a referenced model” – Is My Simulation Valid?
Hello,
I am performing a Processor-in-the-Loop (PIL) simulation on a control subsystem of a fuel-cell model using Simulink/Simscape and an STM32F429 target with Embedded Coder.
I used the option "Create SIL/PIL block" for the subsystem, followed by C/C++ Code > Build This Subsystem, and then added the generated block to my model for testing(fuel-cell model).
When I run the simulation, I get the following warning:
"Top model does not contain a referenced model. ‘Simulation’ and ‘SIL/PIL Simulation’ will behave in the same way. Change ‘system under test’ or add a model block to the top model."
At the same time, the simulation output curves for normal simulation and PIL are identical (confondues), which is expected, but this warning makes me unsure.
My questions:
Does this warning indicate that the PIL simulation is not actually running on the target hardware?
Since I’m testing only a control subsystem using a PIL block, and not the entire model, is it safe to ignore this warning?
Do I need to replace the subsystem with a referenced model (Model block) to properly use PIL at the top level?
Thank you in advance for your help!Hello,
I am performing a Processor-in-the-Loop (PIL) simulation on a control subsystem of a fuel-cell model using Simulink/Simscape and an STM32F429 target with Embedded Coder.
I used the option "Create SIL/PIL block" for the subsystem, followed by C/C++ Code > Build This Subsystem, and then added the generated block to my model for testing(fuel-cell model).
When I run the simulation, I get the following warning:
"Top model does not contain a referenced model. ‘Simulation’ and ‘SIL/PIL Simulation’ will behave in the same way. Change ‘system under test’ or add a model block to the top model."
At the same time, the simulation output curves for normal simulation and PIL are identical (confondues), which is expected, but this warning makes me unsure.
My questions:
Does this warning indicate that the PIL simulation is not actually running on the target hardware?
Since I’m testing only a control subsystem using a PIL block, and not the entire model, is it safe to ignore this warning?
Do I need to replace the subsystem with a referenced model (Model block) to properly use PIL at the top level?
Thank you in advance for your help! Hello,
I am performing a Processor-in-the-Loop (PIL) simulation on a control subsystem of a fuel-cell model using Simulink/Simscape and an STM32F429 target with Embedded Coder.
I used the option "Create SIL/PIL block" for the subsystem, followed by C/C++ Code > Build This Subsystem, and then added the generated block to my model for testing(fuel-cell model).
When I run the simulation, I get the following warning:
"Top model does not contain a referenced model. ‘Simulation’ and ‘SIL/PIL Simulation’ will behave in the same way. Change ‘system under test’ or add a model block to the top model."
At the same time, the simulation output curves for normal simulation and PIL are identical (confondues), which is expected, but this warning makes me unsure.
My questions:
Does this warning indicate that the PIL simulation is not actually running on the target hardware?
Since I’m testing only a control subsystem using a PIL block, and not the entire model, is it safe to ignore this warning?
Do I need to replace the subsystem with a referenced model (Model block) to properly use PIL at the top level?
Thank you in advance for your help! pil MATLAB Answers — New Questions
How to get a smooth scalar field on regular grids from irregularly distributed sample data?
I have irregularly distributed sample data (Rs, Zs, phi00), its contourf plot looks smooth like:
I use:
phi=griddata(Rs,Zs,phi00,Rgrid,Zgrid,’cubic’);
to get the data on regular grids. There are some zigzags on the contourf plot from regular grids like:
Since we can get a smooth contourf plot from the irregular sample data, I believe that there must a simple way to get the smooth data on regular grids. How can I get it?
The sample data points and the contourf plot and the scatteredinterpolant figures are:I have irregularly distributed sample data (Rs, Zs, phi00), its contourf plot looks smooth like:
I use:
phi=griddata(Rs,Zs,phi00,Rgrid,Zgrid,’cubic’);
to get the data on regular grids. There are some zigzags on the contourf plot from regular grids like:
Since we can get a smooth contourf plot from the irregular sample data, I believe that there must a simple way to get the smooth data on regular grids. How can I get it?
The sample data points and the contourf plot and the scatteredinterpolant figures are: I have irregularly distributed sample data (Rs, Zs, phi00), its contourf plot looks smooth like:
I use:
phi=griddata(Rs,Zs,phi00,Rgrid,Zgrid,’cubic’);
to get the data on regular grids. There are some zigzags on the contourf plot from regular grids like:
Since we can get a smooth contourf plot from the irregular sample data, I believe that there must a simple way to get the smooth data on regular grids. How can I get it?
The sample data points and the contourf plot and the scatteredinterpolant figures are: interpolation MATLAB Answers — New Questions
Frequency response estimation error
error:In "frestimate(modelname,op,io,in)", it is required for each of the linearization input I/O points that the sample time of the Simulink signal where it is located is one of the following:
1. It is either continuous or fixed in minor time step.
2. Its sample rate is equal to the sample rate of the input signal "in".
The linearization I/O io(1) does not satisfy this requirement. Consider either changing the sample time of Simulink signal where io(1) is located to continuous sample time or changing the sample time of input signal "in".
However, my sampling time is already set to the same, why do I still get this error?error:In "frestimate(modelname,op,io,in)", it is required for each of the linearization input I/O points that the sample time of the Simulink signal where it is located is one of the following:
1. It is either continuous or fixed in minor time step.
2. Its sample rate is equal to the sample rate of the input signal "in".
The linearization I/O io(1) does not satisfy this requirement. Consider either changing the sample time of Simulink signal where io(1) is located to continuous sample time or changing the sample time of input signal "in".
However, my sampling time is already set to the same, why do I still get this error? error:In "frestimate(modelname,op,io,in)", it is required for each of the linearization input I/O points that the sample time of the Simulink signal where it is located is one of the following:
1. It is either continuous or fixed in minor time step.
2. Its sample rate is equal to the sample rate of the input signal "in".
The linearization I/O io(1) does not satisfy this requirement. Consider either changing the sample time of Simulink signal where io(1) is located to continuous sample time or changing the sample time of input signal "in".
However, my sampling time is already set to the same, why do I still get this error? pid control, model linearizer, simulink control design MATLAB Answers — New Questions
What is the fastest way to solve small linear programs inside a loop?
Hi,
I’m running linprog inside a large time loop to solve small (m,n <=3) linear programs but it is my code’s bottle neck. I found that using Simplex ("Large scale off) instead of interior point in the options makes it a little faster. Is there a faster way to do this? matrix "A" is always small and dense (m,n<=3). I tried TOMLAB’s MINOS and LPOPT and QPOPT but still linprog is faster. I don’t know maybe i’m not using TOMLAB correctly or that they’re just better for large problem sizes.
Is there an easy way to just code a faster LP solver for small problems. For my current problem linprog is taking ~.0012 sec for a single iteration to solve 2*2 problems. I have it inside a nested loop, below is a pseudo code:
for t =1:nt
for n = 1:N
linprog
end
end
So it would be much better to have it to be as fast as say ~0.0005 sec/iteration. I want to do this before attempting to make the inner loop parallel. The outer loop cannot be made parallel because of dependencies (time loop).
I would highly appreciate any help guys because my simulations need to be faster than real-time.
Thanks,
EyasHi,
I’m running linprog inside a large time loop to solve small (m,n <=3) linear programs but it is my code’s bottle neck. I found that using Simplex ("Large scale off) instead of interior point in the options makes it a little faster. Is there a faster way to do this? matrix "A" is always small and dense (m,n<=3). I tried TOMLAB’s MINOS and LPOPT and QPOPT but still linprog is faster. I don’t know maybe i’m not using TOMLAB correctly or that they’re just better for large problem sizes.
Is there an easy way to just code a faster LP solver for small problems. For my current problem linprog is taking ~.0012 sec for a single iteration to solve 2*2 problems. I have it inside a nested loop, below is a pseudo code:
for t =1:nt
for n = 1:N
linprog
end
end
So it would be much better to have it to be as fast as say ~0.0005 sec/iteration. I want to do this before attempting to make the inner loop parallel. The outer loop cannot be made parallel because of dependencies (time loop).
I would highly appreciate any help guys because my simulations need to be faster than real-time.
Thanks,
Eyas Hi,
I’m running linprog inside a large time loop to solve small (m,n <=3) linear programs but it is my code’s bottle neck. I found that using Simplex ("Large scale off) instead of interior point in the options makes it a little faster. Is there a faster way to do this? matrix "A" is always small and dense (m,n<=3). I tried TOMLAB’s MINOS and LPOPT and QPOPT but still linprog is faster. I don’t know maybe i’m not using TOMLAB correctly or that they’re just better for large problem sizes.
Is there an easy way to just code a faster LP solver for small problems. For my current problem linprog is taking ~.0012 sec for a single iteration to solve 2*2 problems. I have it inside a nested loop, below is a pseudo code:
for t =1:nt
for n = 1:N
linprog
end
end
So it would be much better to have it to be as fast as say ~0.0005 sec/iteration. I want to do this before attempting to make the inner loop parallel. The outer loop cannot be made parallel because of dependencies (time loop).
I would highly appreciate any help guys because my simulations need to be faster than real-time.
Thanks,
Eyas linprog, optimization, loops, speed, linear program, linear programming, nested loops, real time, simulation, tomlab, optimization toolbox, simplex, mathematics, parallel computing, mex MATLAB Answers — New Questions
New Outlook and OWA Control for Viewing Protected Email
Force Two-Click Confirmation to View Email Protected by Sensitivity Labels
Recently I noticed that OWA behaved differently when previewing email protected by sensitivity labels. Because it’s an online client, OWA has always been able to seamlessly retrieve the authorization to open and display protected messages from the rights management service. Now a message said that organization policies mandate clicking “View message” to access the email content (Figure 1).

It’s no big deal to comply with the demand for the extra click, but what organizational policies are at work here?
The New Setting for Two-Click Confirmation
The answer lies in the Exchange Online organization configuration, specifically the TwoClickMailPreviewEnabled setting. In my tenant, the setting is True, meaning that it’s enabled and forcing OWA to demand the extra click.
But here’s the thing. According to message center notification MC1041456 (26 March 2025, Microsoft 365 roadmap item 483883), the two-click requirement to view protected messages rolled out to general availability in early April 2025 and should be now be complete worldwide. The notification mentions encrypted emails. I have no idea if the feature extends to messages protected with S/MIME or another type of encryption other than Purview sensitivity labels. I hadn’t seen the behavior in OWA before because I’ve been using the new Outlook for Windows. According to MC1041456, the setting should affect that client too, but it doesn’t. The new Outlook ignores the TwoClickMailPreviewEnabled setting and opens protected messages without as much as a brief pause (Figure 2). Perhaps the client is awaiting an update to respect the setting.

The TwoClickMailPreviewEnabled setting doesn’t affect Outlook classic. That client uses a different mechanism to fetch authorization to open protected messages (to allow Outlook to work offline).
Configuring Two-Click Confirmation
A mismatch between documented setting and client behavior isn’t the only thing that’s odd about the information contained in MC1041456. First, the text refers to the setting being in the Microsoft Azure directory. It’s not. The setting is in the Exchange organization configuration. I’m not saying that the setting doesn’t exist somewhere in Entra ID (which I assume the text refers to), but the instructions given to maintain the setting use Exchange Online cmdlets.
MC1041456 asserts “By default, the two-click setting is off.” I checked by running the Get-OrganizationConfig cmdlet and found that the setting is true (enabled):
Get-OrganizationConfig | fl two* TwoClickMailPreviewEnabled : True
Obviously, somewhere along the line between the message center notification appearing and now the setting had been changed, probably by me. To reset the setting and remove the requirement for double clicks, I ran:
Set-OrganizationConfig -TwoClickMailPreviewEnabled $false
(MC1041456 refers to Boolean values. You can use $false or 0 to update the setting).
Prompts to use OneDrive
When checking out two-click confirmation, I noticed that both OWA and the new Outlook nag users to use OneDrive to share files rather than uploading copies of files as attachments (Figure 3). This is the effect of MC1053121 (last updated 15 May 2025) to have the Office apps prompt users to make more use of OneDrive. The update is now generally available. I don’t like this kind of nagging and recommend that organizations take the time to review the information in MC1053121 and consider if you want to block the nagging.

Two-Click Confirmation Can be Valuable
Microsoft doesn’t give any clues why they think it is a good idea to “require user confirmation before allowing access to encrypted emails.” My assumption is that the reason has to do with privacy. No one wants to have a confidential message pop up on screen when a chance exists that the information could be read by someone else.
However, in other situations where people have grown used to reading confidential messages without hindrance, they might find two-click confirmation a tiresome restriction on their workflow. The bad thing about the feature is that it’s either on or off for an entire tenant without any ability to grant exclusions.
Forcing the double click confirmation allows the recipient to wait until they’re sure that no one can look over their shoulder or otherwise see the content before going ahead. The volume of notifications that flood into tenants mean that features like this can go by without being noted by administrators. If administrators don’t know about a feature, it can’t be used. And that’s a bad thing.
So much change, all the time. It’s a challenge to stay abreast of all the updates Microsoft makes across the Microsoft 365 ecosystem. Subscribe to the Office 365 for IT Pros eBook to receive monthly insights into what happens, why it happens, and what new features and capabilities mean for your tenant.
AXI4-Stream to Software clock frequency does not match FPGA clock frequency
Dear all,
I am using SoC Blockset add-on and checking out the example "Transmit and Receive Tone Using RFSoC Device" (https://www.mathworks.com/help/soc/ug/transmit-and-receive-tone-using-RFSoC-device-simulate.html). The FPGA Clock frequency (SampleTime) is set to 128MHz, but the AXI4-Stream to Software clock is set to 200MHz. How are then all the samples written to memory if the memory clock is slower than the sample production frequency?
How does in general AXI4-Stream to Software block work? The following qustions are not answered in the documentation (https://www.mathworks.com/help/soc/ref/axi4streamtosoftware.html):
1) Does one buffer contatin multiple bursts? If yes, how many?
2) With what rate is burst written to buffer?
3) With what rate are samples saved in burst (to be written to buffer later)?
4) Are samples written to FIFO with the same rate as in the previous question?
Thank you!Dear all,
I am using SoC Blockset add-on and checking out the example "Transmit and Receive Tone Using RFSoC Device" (https://www.mathworks.com/help/soc/ug/transmit-and-receive-tone-using-RFSoC-device-simulate.html). The FPGA Clock frequency (SampleTime) is set to 128MHz, but the AXI4-Stream to Software clock is set to 200MHz. How are then all the samples written to memory if the memory clock is slower than the sample production frequency?
How does in general AXI4-Stream to Software block work? The following qustions are not answered in the documentation (https://www.mathworks.com/help/soc/ref/axi4streamtosoftware.html):
1) Does one buffer contatin multiple bursts? If yes, how many?
2) With what rate is burst written to buffer?
3) With what rate are samples saved in burst (to be written to buffer later)?
4) Are samples written to FIFO with the same rate as in the previous question?
Thank you! Dear all,
I am using SoC Blockset add-on and checking out the example "Transmit and Receive Tone Using RFSoC Device" (https://www.mathworks.com/help/soc/ug/transmit-and-receive-tone-using-RFSoC-device-simulate.html). The FPGA Clock frequency (SampleTime) is set to 128MHz, but the AXI4-Stream to Software clock is set to 200MHz. How are then all the samples written to memory if the memory clock is slower than the sample production frequency?
How does in general AXI4-Stream to Software block work? The following qustions are not answered in the documentation (https://www.mathworks.com/help/soc/ref/axi4streamtosoftware.html):
1) Does one buffer contatin multiple bursts? If yes, how many?
2) With what rate is burst written to buffer?
3) With what rate are samples saved in burst (to be written to buffer later)?
4) Are samples written to FIFO with the same rate as in the previous question?
Thank you! clock, soc blockset, axi4-stream to software, axi4, fpga, sampling, fifo, buffer, burst, clock frequency MATLAB Answers — New Questions
Help to understand RF Data Converter clocking
Dear all,
I am starting to use SoC Blockset add-on and now figuring out how RF Data Converter block works.
For example I set the following parameters in RF Data Converter:
(Sample rate 1024 MSPS, Interpolation/Decimation 1, Samples per clock cycle 4 –> Stream Clock Frequency 256MHz)
The FPGA sampling time is also set to 7.1825e-9 to correspond to Stream Clock Frequency of 256MHz.
Then, in the timing manager we can see, that the RF Data Converter transmits (updates the output dacTxChy) with Stream Clock Frequency of 256MHz.
Now we can set Interpolation/Decimation to 2 (This changes Stream Clock Frequency to 128MHz. The FPGA sampling time is unchanged.
We can now see, that RF Data Converter updates the output dacTxChy with Stream Clock Frequency of 128MHz. This "eats" some of the FPGA samples, which is bad, so I am not sure this is how I should use this block.
The question is what Interpolation setting is done for and how to apply it? Is this ok that when I set the Interpolation parameter to the value different from 1 it seems like the actual sampling frequency just decreases without any benefits? Why not then just decrease Sample rate of RF Data Converter? Thank you!Dear all,
I am starting to use SoC Blockset add-on and now figuring out how RF Data Converter block works.
For example I set the following parameters in RF Data Converter:
(Sample rate 1024 MSPS, Interpolation/Decimation 1, Samples per clock cycle 4 –> Stream Clock Frequency 256MHz)
The FPGA sampling time is also set to 7.1825e-9 to correspond to Stream Clock Frequency of 256MHz.
Then, in the timing manager we can see, that the RF Data Converter transmits (updates the output dacTxChy) with Stream Clock Frequency of 256MHz.
Now we can set Interpolation/Decimation to 2 (This changes Stream Clock Frequency to 128MHz. The FPGA sampling time is unchanged.
We can now see, that RF Data Converter updates the output dacTxChy with Stream Clock Frequency of 128MHz. This "eats" some of the FPGA samples, which is bad, so I am not sure this is how I should use this block.
The question is what Interpolation setting is done for and how to apply it? Is this ok that when I set the Interpolation parameter to the value different from 1 it seems like the actual sampling frequency just decreases without any benefits? Why not then just decrease Sample rate of RF Data Converter? Thank you! Dear all,
I am starting to use SoC Blockset add-on and now figuring out how RF Data Converter block works.
For example I set the following parameters in RF Data Converter:
(Sample rate 1024 MSPS, Interpolation/Decimation 1, Samples per clock cycle 4 –> Stream Clock Frequency 256MHz)
The FPGA sampling time is also set to 7.1825e-9 to correspond to Stream Clock Frequency of 256MHz.
Then, in the timing manager we can see, that the RF Data Converter transmits (updates the output dacTxChy) with Stream Clock Frequency of 256MHz.
Now we can set Interpolation/Decimation to 2 (This changes Stream Clock Frequency to 128MHz. The FPGA sampling time is unchanged.
We can now see, that RF Data Converter updates the output dacTxChy with Stream Clock Frequency of 128MHz. This "eats" some of the FPGA samples, which is bad, so I am not sure this is how I should use this block.
The question is what Interpolation setting is done for and how to apply it? Is this ok that when I set the Interpolation parameter to the value different from 1 it seems like the actual sampling frequency just decreases without any benefits? Why not then just decrease Sample rate of RF Data Converter? Thank you! soc blockset, rf data converter, sampling frequency, interpolation, clocking, fpga, dac, adc MATLAB Answers — New Questions
Cannot find SoCData and rteEvent datatypes characteristics
Dear all,
I was trying to figure out the following about SoCData datatype:
1) What are its dimensions?
2) Is this real or complex signal?
Could you, please, help me to find information about this? Same qustion concerning rteEvent datatype. These datatypes are output datatypes or AXI4-Stream to Software block. I also had a feeling that these might be messages, not signals. Is this correct or not?Dear all,
I was trying to figure out the following about SoCData datatype:
1) What are its dimensions?
2) Is this real or complex signal?
Could you, please, help me to find information about this? Same qustion concerning rteEvent datatype. These datatypes are output datatypes or AXI4-Stream to Software block. I also had a feeling that these might be messages, not signals. Is this correct or not? Dear all,
I was trying to figure out the following about SoCData datatype:
1) What are its dimensions?
2) Is this real or complex signal?
Could you, please, help me to find information about this? Same qustion concerning rteEvent datatype. These datatypes are output datatypes or AXI4-Stream to Software block. I also had a feeling that these might be messages, not signals. Is this correct or not? datatype, soc blockset, socdata, dimension, signal attributes MATLAB Answers — New Questions
No more m-file app packaging…
Hi, is it correct that GUIs built programatically (as an m file using uicontrol) can no longer be converted to a mlappinstall file in 2025a? It seems like my GUI (PIVlab) can now only be shared on file exchange as a "pure toolbox" that will be installed in a completely "random" folder (/…/…/…/AppData/Roaming/…/…/…/…/…). None of my users (including me) will intuitively know how to start the GUI. In older releases, an App could be added to the "App badge", making it very easy for new Matlab users to start the GUI. But there doesn’t seem to be a clean way to convert m-files to mlappisntall anymore. Previously an "App project" could be used together with the matlab.apputil.package could be used. Now Matlab tells me that "To package an app, create a MATLAB toolbox. "
I did that, but I cannot add an .m file as App.Hi, is it correct that GUIs built programatically (as an m file using uicontrol) can no longer be converted to a mlappinstall file in 2025a? It seems like my GUI (PIVlab) can now only be shared on file exchange as a "pure toolbox" that will be installed in a completely "random" folder (/…/…/…/AppData/Roaming/…/…/…/…/…). None of my users (including me) will intuitively know how to start the GUI. In older releases, an App could be added to the "App badge", making it very easy for new Matlab users to start the GUI. But there doesn’t seem to be a clean way to convert m-files to mlappisntall anymore. Previously an "App project" could be used together with the matlab.apputil.package could be used. Now Matlab tells me that "To package an app, create a MATLAB toolbox. "
I did that, but I cannot add an .m file as App. Hi, is it correct that GUIs built programatically (as an m file using uicontrol) can no longer be converted to a mlappinstall file in 2025a? It seems like my GUI (PIVlab) can now only be shared on file exchange as a "pure toolbox" that will be installed in a completely "random" folder (/…/…/…/AppData/Roaming/…/…/…/…/…). None of my users (including me) will intuitively know how to start the GUI. In older releases, an App could be added to the "App badge", making it very easy for new Matlab users to start the GUI. But there doesn’t seem to be a clean way to convert m-files to mlappisntall anymore. Previously an "App project" could be used together with the matlab.apputil.package could be used. Now Matlab tells me that "To package an app, create a MATLAB toolbox. "
I did that, but I cannot add an .m file as App. mlappinstall, app, toolbox, apputil MATLAB Answers — New Questions
How can I download the 30 Day Trial Version?
Hello all,
i have problems with my Account. I can not download the 30 Day Trial Version of MATLAB. Can anyone help me please?
With best RegardsHello all,
i have problems with my Account. I can not download the 30 Day Trial Version of MATLAB. Can anyone help me please?
With best Regards Hello all,
i have problems with my Account. I can not download the 30 Day Trial Version of MATLAB. Can anyone help me please?
With best Regards account, trial version MATLAB Answers — New Questions
June 2025 Update Available for Office 365 for IT Pros (2025 Edition)
Monthly Update #120 Now Available for Subscribers to Download

The Office 365 for IT Pros team is delighted to announce the availability of monthly update #120 for the Office 365 for IT Pros (2025 edition) eBook. Updated PDF and EPUB files are available for the main book and for the Automating Microsoft 365 with PowerShell eBook (previously released last week). The files can be downloaded using the link in the receipt subscribers received when they bought the book or from their Gumroad accounts. See our FAQ for more information about downloading updates and the change log for information about changes made in this update.
This is the last monthly update for the 2025 edition. We plan to release the 2026 edition on July 1, 2025, and begin a new cycle of monthly updates (#121 to #132) to bring us to June 2026. We’ll let subscribers know when the 2026 edition is available and it is our sincere hope that you’ll all join us for another year of constant change across the Microsoft 365 ecosystem. As is our normal practice, anyone who buys the 2025 edition at full price during June 2025 will receive a free upgrade to the 2026 edition when it is available.
Seeking a Million Prompts
As we prepare for the new edition, we keep our eyes open for news that we might like to cover. One interesting item that won’t make it into the book is the news that Shoosmiths, a UK-based law firm will share a £1m sterling bonus among its employees if the employees clock up one million Microsoft Copilot prompts in its new financial year. Presumably, the prompts will be counted using the aiInteractionHistory Graph API or audit records.
Shoosmiths estimates that the target will be achieved if each employee uses Copilot “4 times per working day.” That target shouldn’t be too hard to meet. Law firms are prolific users of documents, so the automatic summaries generated by Copilot in Word will go a long way to achieving the bonus (which might not be what the Shoosmiths bosses anticipated).
Microsoft 365 Gets to 430 Million Paid Seats
I usually write about Microsoft’s quarterly results but failed to do so for the FY25 Q3 announcement. The reason is simple: the data shared by Microsoft is great from a financial perspective (revenue was $70.1 billion and increased 13% (up 15% in constant currency)), but poor in terms of Microsoft 365 news. Where once it was common for Microsoft to report growth in seat numbers and other details, now it’s all about spending on artificial intelligence and the growth of agents.
A couple of things did stand out from the transcript of the quarterly results meeting with analysts.
First, Microsoft CFO Amy Hood said that paid Microsoft 365 commercial seats grew to “over 430 million,” a growth of 7% year-over-year. She also observed that Microsoft 365 seat growth in the current quarter would see “moderation given the size of the installed base.” In other words, Microsoft has signed up so many customers that adding a few extra million seats each quarter barely budges the needle.
However, Hood said that she expected Microsoft 365 revenue growth of 14%. The gap between seat growth and revenue growth is accounted for customers buying upgraded licenses, including moving lower-level licenses to Microsoft 365 E5 and buying Microsoft 365 Copilot.
The quarterly results didn’t mention Teams, the poster child of Microsoft 365 for the last few years, The last number given for Teams users was 320 million in October 2023. If growth in Teams usage had matched Microsoft 365, that number would be around 350 million now. Instead, CEO Nadella chose to emphasize the growth in Power Platform, saying “We now have 56 million monthly active Power Platform users, up 27% year-over-year, who increasingly use our AI features to build apps and automate processes.” He also said that Copilot usage increased three times year-over-year, but that’s a useless statistic without knowing the baseline.
Office 365 for IT Pros Enters an Agentic World
Obviously, there’s a lot of people using Power Platform (about 13.25% of all paid seats). Some of that growth probably comes from Copilot agents. Microsoft doesn’t have a great story about management of agent lifecycle, deployment, and access across a Microsoft 365 tenant, and the announcement that Entra ID will deliver some agent management capabilities in the Entra admin center is a good step forward. Technology keeps on changing, and we keep on tracking that change through updates to Office 365 for IT Pros. Onward to the 2026 edition!
How can I simulate a pv/wind/battery hybrid microgrid for a rural area in kapiri with errors?
Those are my values for the area I’ve chosen and simulated block diagrams that I tried to simulate but the waveforms are not being produced. Please help me spot the mistakes I made and help with simulations that would with my area specifications.Those are my values for the area I’ve chosen and simulated block diagrams that I tried to simulate but the waveforms are not being produced. Please help me spot the mistakes I made and help with simulations that would with my area specifications. Those are my values for the area I’ve chosen and simulated block diagrams that I tried to simulate but the waveforms are not being produced. Please help me spot the mistakes I made and help with simulations that would with my area specifications. final year project MATLAB Answers — New Questions
Need a tangent line in my plot like the example provided but I cannot seem to do it
I am trying to make a tangent or line of best fit t this data but only from the second half of the plot on should be focused on. Below is an example from the professor
Need smething like this…
which translates to something like this…
But for some reason I keep getting this…
By using this code…
%% Calculation Problem 2
%Given Data Problems 1-4
dd = load(‘NEWPROB6.txt’) %Data loading for airfoil
alpha = dd(:,1); %Angle of attacks (Degreed)
CL = dd(:,2); %Lift coefficient
CD = dd(:,3); %Drag coefficient
Rh = 0.75; %Turbine hub radius (m)
Rt = 15; %Turbine blade tip radius (m)
Rht = linspace(Rh,Rt,10); %r/R radius hub to tip (m)
Rr = Rht/Rt;
B = 3; %Number of blades on the turbine
TSR = 8; %Tips-speed ratio
%Calculation Problem 1
CLD = CL./CD %Lift-to-Drag Ratio
TCL = 1.0280 %Lift coefficient associated with maximum lift-to-drag ratio
Talpha = 6 %Target angle of attack (degrees)
%Calculation Problem 2
Phi = atand(2./(3*TSR*(Rr))) %Local inflow angle (degrees)
CrR = Rt*(8*pi*sind(Phi))./(3*B*TCL*TSR); %chord distribution
Beta = Phi-Talpha
subplot(2,1,1)
plot(Rht,CrR, ‘b.-‘, ‘LineWidth’,2, ‘MarkerSize’, 20)
halfpoints = round(numel(CrR)/2)
xlabel(‘r/R’)
ylabel(‘Chord Distribution (m)’)
grid on
hold on
% Assume x and y are your data vectors
xline(Rht(halfpoints), ‘Color’, ‘r’)
% Get halfway index
RhtHalf = Rht(halfpoints : end)
CrRHalf = CrR(halfpoints : end)
coefficients = polyfit(RhtHalf, CrRHalf, 1)
RhtFitted = linspace(5, 10, 1)
CrRFitted = polyval(coefficients, RhtFitted);
plot(RhtFitted, CrRFitted, ‘c–‘, ‘LineWidth’, 2)
grid on
legend(‘Original Data’, ‘Linear Fit (2nd Half)’);
hold off
Does anyone know how I can fix this?I am trying to make a tangent or line of best fit t this data but only from the second half of the plot on should be focused on. Below is an example from the professor
Need smething like this…
which translates to something like this…
But for some reason I keep getting this…
By using this code…
%% Calculation Problem 2
%Given Data Problems 1-4
dd = load(‘NEWPROB6.txt’) %Data loading for airfoil
alpha = dd(:,1); %Angle of attacks (Degreed)
CL = dd(:,2); %Lift coefficient
CD = dd(:,3); %Drag coefficient
Rh = 0.75; %Turbine hub radius (m)
Rt = 15; %Turbine blade tip radius (m)
Rht = linspace(Rh,Rt,10); %r/R radius hub to tip (m)
Rr = Rht/Rt;
B = 3; %Number of blades on the turbine
TSR = 8; %Tips-speed ratio
%Calculation Problem 1
CLD = CL./CD %Lift-to-Drag Ratio
TCL = 1.0280 %Lift coefficient associated with maximum lift-to-drag ratio
Talpha = 6 %Target angle of attack (degrees)
%Calculation Problem 2
Phi = atand(2./(3*TSR*(Rr))) %Local inflow angle (degrees)
CrR = Rt*(8*pi*sind(Phi))./(3*B*TCL*TSR); %chord distribution
Beta = Phi-Talpha
subplot(2,1,1)
plot(Rht,CrR, ‘b.-‘, ‘LineWidth’,2, ‘MarkerSize’, 20)
halfpoints = round(numel(CrR)/2)
xlabel(‘r/R’)
ylabel(‘Chord Distribution (m)’)
grid on
hold on
% Assume x and y are your data vectors
xline(Rht(halfpoints), ‘Color’, ‘r’)
% Get halfway index
RhtHalf = Rht(halfpoints : end)
CrRHalf = CrR(halfpoints : end)
coefficients = polyfit(RhtHalf, CrRHalf, 1)
RhtFitted = linspace(5, 10, 1)
CrRFitted = polyval(coefficients, RhtFitted);
plot(RhtFitted, CrRFitted, ‘c–‘, ‘LineWidth’, 2)
grid on
legend(‘Original Data’, ‘Linear Fit (2nd Half)’);
hold off
Does anyone know how I can fix this? I am trying to make a tangent or line of best fit t this data but only from the second half of the plot on should be focused on. Below is an example from the professor
Need smething like this…
which translates to something like this…
But for some reason I keep getting this…
By using this code…
%% Calculation Problem 2
%Given Data Problems 1-4
dd = load(‘NEWPROB6.txt’) %Data loading for airfoil
alpha = dd(:,1); %Angle of attacks (Degreed)
CL = dd(:,2); %Lift coefficient
CD = dd(:,3); %Drag coefficient
Rh = 0.75; %Turbine hub radius (m)
Rt = 15; %Turbine blade tip radius (m)
Rht = linspace(Rh,Rt,10); %r/R radius hub to tip (m)
Rr = Rht/Rt;
B = 3; %Number of blades on the turbine
TSR = 8; %Tips-speed ratio
%Calculation Problem 1
CLD = CL./CD %Lift-to-Drag Ratio
TCL = 1.0280 %Lift coefficient associated with maximum lift-to-drag ratio
Talpha = 6 %Target angle of attack (degrees)
%Calculation Problem 2
Phi = atand(2./(3*TSR*(Rr))) %Local inflow angle (degrees)
CrR = Rt*(8*pi*sind(Phi))./(3*B*TCL*TSR); %chord distribution
Beta = Phi-Talpha
subplot(2,1,1)
plot(Rht,CrR, ‘b.-‘, ‘LineWidth’,2, ‘MarkerSize’, 20)
halfpoints = round(numel(CrR)/2)
xlabel(‘r/R’)
ylabel(‘Chord Distribution (m)’)
grid on
hold on
% Assume x and y are your data vectors
xline(Rht(halfpoints), ‘Color’, ‘r’)
% Get halfway index
RhtHalf = Rht(halfpoints : end)
CrRHalf = CrR(halfpoints : end)
coefficients = polyfit(RhtHalf, CrRHalf, 1)
RhtFitted = linspace(5, 10, 1)
CrRFitted = polyval(coefficients, RhtFitted);
plot(RhtFitted, CrRFitted, ‘c–‘, ‘LineWidth’, 2)
grid on
legend(‘Original Data’, ‘Linear Fit (2nd Half)’);
hold off
Does anyone know how I can fix this? tangent line, line of best fit, regression line, plotting, matlab MATLAB Answers — New Questions
Looking for sensor in simulink to sense distance between two vehicles
I am trying to find a sensor in the simulink library to detect distance between two vehicles. I am doing my final year project which is a fuzzy logic collision avoidance system. I am trying to model it using matlab and simulink. Can anyone point me in the right direction with respect to where i can find the sensor input in the library? Also i am looking for one to detect the rate of change in velocity of the vehicle in front of the other one.I am trying to find a sensor in the simulink library to detect distance between two vehicles. I am doing my final year project which is a fuzzy logic collision avoidance system. I am trying to model it using matlab and simulink. Can anyone point me in the right direction with respect to where i can find the sensor input in the library? Also i am looking for one to detect the rate of change in velocity of the vehicle in front of the other one. I am trying to find a sensor in the simulink library to detect distance between two vehicles. I am doing my final year project which is a fuzzy logic collision avoidance system. I am trying to model it using matlab and simulink. Can anyone point me in the right direction with respect to where i can find the sensor input in the library? Also i am looking for one to detect the rate of change in velocity of the vehicle in front of the other one. simulink, matlab MATLAB Answers — New Questions
Word Matlab Notebook and figures…
Have a script generating several figures — may be 10 or more eventually.
Need to use these in a Word document for distribution so thought the *notebook* thingie would be pretty simple–just execute the script and voila! the figures should show up (or so I thought, anyways).
Instead the script runs, I see the figures flash by, but all that’s left in the document is the last one; none of the rest are to be found anywhere.
Is this expected; if not how to cure the symptom in R2012b or if is a limitation, is there some other quick ‘n dirty way to accomplish the job?Have a script generating several figures — may be 10 or more eventually.
Need to use these in a Word document for distribution so thought the *notebook* thingie would be pretty simple–just execute the script and voila! the figures should show up (or so I thought, anyways).
Instead the script runs, I see the figures flash by, but all that’s left in the document is the last one; none of the rest are to be found anywhere.
Is this expected; if not how to cure the symptom in R2012b or if is a limitation, is there some other quick ‘n dirty way to accomplish the job? Have a script generating several figures — may be 10 or more eventually.
Need to use these in a Word document for distribution so thought the *notebook* thingie would be pretty simple–just execute the script and voila! the figures should show up (or so I thought, anyways).
Instead the script runs, I see the figures flash by, but all that’s left in the document is the last one; none of the rest are to be found anywhere.
Is this expected; if not how to cure the symptom in R2012b or if is a limitation, is there some other quick ‘n dirty way to accomplish the job? word notebook, figures MATLAB Answers — New Questions
How do I dock figures next to the editor by default ?
set(0,’DefaultFigureWindowStyle’,’docked’) does not work. It still opens the figure in a new windows an I have to right click and click on "Dock figures". Alternatively I can press CTRL+Shift+D but I dont want to do that. Typing get(0,’DefaultFigureWindowStyle’) gives me "docked" as an answer so the command is working appearently.
How can I make it so the figure appears next to the editor by default without me pressing CTRL+Shift+D everytime ?set(0,’DefaultFigureWindowStyle’,’docked’) does not work. It still opens the figure in a new windows an I have to right click and click on "Dock figures". Alternatively I can press CTRL+Shift+D but I dont want to do that. Typing get(0,’DefaultFigureWindowStyle’) gives me "docked" as an answer so the command is working appearently.
How can I make it so the figure appears next to the editor by default without me pressing CTRL+Shift+D everytime ? set(0,’DefaultFigureWindowStyle’,’docked’) does not work. It still opens the figure in a new windows an I have to right click and click on "Dock figures". Alternatively I can press CTRL+Shift+D but I dont want to do that. Typing get(0,’DefaultFigureWindowStyle’) gives me "docked" as an answer so the command is working appearently.
How can I make it so the figure appears next to the editor by default without me pressing CTRL+Shift+D everytime ? figure, graph, matlab, gui, default MATLAB Answers — New Questions