Category: Matlab
Category Archives: Matlab
Discrete Phasor domain in Simscape
Dear community,
Is it possible to create an electrical model using Simscape blocks (blue ones) and solve it in Discrete Phasor domain, i.e. RMS quantities (as it can be done using Specialized Power Systems)?
If not, is there any other alternative?
Thank you very much in advance.
Best regards,
Víctor Sánchez SuárezDear community,
Is it possible to create an electrical model using Simscape blocks (blue ones) and solve it in Discrete Phasor domain, i.e. RMS quantities (as it can be done using Specialized Power Systems)?
If not, is there any other alternative?
Thank you very much in advance.
Best regards,
Víctor Sánchez Suárez Dear community,
Is it possible to create an electrical model using Simscape blocks (blue ones) and solve it in Discrete Phasor domain, i.e. RMS quantities (as it can be done using Specialized Power Systems)?
If not, is there any other alternative?
Thank you very much in advance.
Best regards,
Víctor Sánchez Suárez simscape, discrete phasor, rms, specialized power systems MATLAB Answers — New Questions
How do I exclude the first ten observations in the line plot generated by the three differential equations
close all
clear all
clc
tspan = [0 100];
y0 = 0.7; % initial value of state variable x1
r0 = 0.7; % initial value of state variable x2
w0 = 0.8; % initial value of state variable x3
x0 = [y0; r0; w0];
[t, x] = ode45(@odefcn, tspan, x0);
%% Plot x2 (y-axis) vs. x1 (x-axis)
subplot(3,1,1);
plot(t,x(:,1));
xlabel(‘Time’)
ylabel(‘Output’);
subplot(3,1,2);
plot(t,x(:,2));
xlabel(‘Time’)
ylabel(‘Policy Rate’);
subplot(3,1,3);
plot(t,x(:,3));
xlabel(‘Time’)
ylabel(‘Wage Share’);
y0 = [0.7; 0.7; 0.8];
%% System of three differential equations
function dx = odefcn(t, x)
% definitions
y = x(1);
r = x(2);
w = x(3);
% parameters
alpha = 1.0;
beta = 1.0;
gamma = 0.1;
delta = 0.3;
mu = 1.0;
lambda = 0.3;
theta = 0.1;
omega = 0.2;
% ODEs
dx(1,1) = alpha * y – beta * r * y;
dx(2,1) = – omega * r + gamma * w * r + delta * y * r;
dx(3,1) = – theta * w + lambda * y * w – mu * w * w;
endclose all
clear all
clc
tspan = [0 100];
y0 = 0.7; % initial value of state variable x1
r0 = 0.7; % initial value of state variable x2
w0 = 0.8; % initial value of state variable x3
x0 = [y0; r0; w0];
[t, x] = ode45(@odefcn, tspan, x0);
%% Plot x2 (y-axis) vs. x1 (x-axis)
subplot(3,1,1);
plot(t,x(:,1));
xlabel(‘Time’)
ylabel(‘Output’);
subplot(3,1,2);
plot(t,x(:,2));
xlabel(‘Time’)
ylabel(‘Policy Rate’);
subplot(3,1,3);
plot(t,x(:,3));
xlabel(‘Time’)
ylabel(‘Wage Share’);
y0 = [0.7; 0.7; 0.8];
%% System of three differential equations
function dx = odefcn(t, x)
% definitions
y = x(1);
r = x(2);
w = x(3);
% parameters
alpha = 1.0;
beta = 1.0;
gamma = 0.1;
delta = 0.3;
mu = 1.0;
lambda = 0.3;
theta = 0.1;
omega = 0.2;
% ODEs
dx(1,1) = alpha * y – beta * r * y;
dx(2,1) = – omega * r + gamma * w * r + delta * y * r;
dx(3,1) = – theta * w + lambda * y * w – mu * w * w;
end close all
clear all
clc
tspan = [0 100];
y0 = 0.7; % initial value of state variable x1
r0 = 0.7; % initial value of state variable x2
w0 = 0.8; % initial value of state variable x3
x0 = [y0; r0; w0];
[t, x] = ode45(@odefcn, tspan, x0);
%% Plot x2 (y-axis) vs. x1 (x-axis)
subplot(3,1,1);
plot(t,x(:,1));
xlabel(‘Time’)
ylabel(‘Output’);
subplot(3,1,2);
plot(t,x(:,2));
xlabel(‘Time’)
ylabel(‘Policy Rate’);
subplot(3,1,3);
plot(t,x(:,3));
xlabel(‘Time’)
ylabel(‘Wage Share’);
y0 = [0.7; 0.7; 0.8];
%% System of three differential equations
function dx = odefcn(t, x)
% definitions
y = x(1);
r = x(2);
w = x(3);
% parameters
alpha = 1.0;
beta = 1.0;
gamma = 0.1;
delta = 0.3;
mu = 1.0;
lambda = 0.3;
theta = 0.1;
omega = 0.2;
% ODEs
dx(1,1) = alpha * y – beta * r * y;
dx(2,1) = – omega * r + gamma * w * r + delta * y * r;
dx(3,1) = – theta * w + lambda * y * w – mu * w * w;
end graphics, subplot, plotting, plot, differential equations MATLAB Answers — New Questions
Abfload error – colon operands must be real scalars
Hi all, we’ve had to transfer some Matlab code to a new computer for analysis of .abf files and moved from version R2018b to R2025a. However abfload is now giving us the error message below. Can anybody suggest a work around? The error message is below.
Error using :
Colon operands must be real scalars.
Error in
abfload (line 304)
h.protocolName=char(BigString(tmpIx1:tmpIx2(1)+3))’;
^Hi all, we’ve had to transfer some Matlab code to a new computer for analysis of .abf files and moved from version R2018b to R2025a. However abfload is now giving us the error message below. Can anybody suggest a work around? The error message is below.
Error using :
Colon operands must be real scalars.
Error in
abfload (line 304)
h.protocolName=char(BigString(tmpIx1:tmpIx2(1)+3))’;
^ Hi all, we’ve had to transfer some Matlab code to a new computer for analysis of .abf files and moved from version R2018b to R2025a. However abfload is now giving us the error message below. Can anybody suggest a work around? The error message is below.
Error using :
Colon operands must be real scalars.
Error in
abfload (line 304)
h.protocolName=char(BigString(tmpIx1:tmpIx2(1)+3))’;
^ abfload, colon operands 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
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
Iterative Solution for Nonlinear System and Comparing Updated Coefficients
I am working with a nonlinear system of equations, where the term ( left| frac{partial phi_2′}{partial r} right| ) appears in the equations. I need to solve the system iteratively and compare the coefficients calculated using the initial assumption (with ( left| frac{partial phi_2′}{partial r} right| = 0 ) at first) with the updated coefficients obtained after several iterations.
The steps of the process are as follows:
begin{itemize}
item textbf{Step A:} Assume that the value of ( left| frac{partial phi_2′}{partial r} right| ) is known (set to 0 initially) and the coefficients ( c_n, c_n^-, d^0, d_n^+, d_n^- ) are unknown. The system of equations becomes linear and can be solved by Gaussian elimination.
item textbf{Step B:} After obtaining the initial solution, substitute the value of ( left| frac{partial phi_2′}{partial r} right| ) into the equation set and solve for all unknown coefficients, and update the value of ( left| frac{partial phi_2′}{partial r} right| ).
item textbf{Step C:} Calculate the updated unknown coefficients, and compare them with the values obtained in the previous iteration. If the difference between any coefficient is smaller than ( 10^{-3} ), stop the iteration and consider the solution as the final result. Otherwise, continue iterating, updating the value of ( left| frac{partial phi_2′}{partial r} right| ) in each step.
end{itemize}
How can I implement this iterative solution in MATLAB? Specifically, how can I calculate and compare the differences between the unknown coefficients obtained in each step using the initial and updated values of ( left| frac{partial phi_2′}{partial r} right| )?I am working with a nonlinear system of equations, where the term ( left| frac{partial phi_2′}{partial r} right| ) appears in the equations. I need to solve the system iteratively and compare the coefficients calculated using the initial assumption (with ( left| frac{partial phi_2′}{partial r} right| = 0 ) at first) with the updated coefficients obtained after several iterations.
The steps of the process are as follows:
begin{itemize}
item textbf{Step A:} Assume that the value of ( left| frac{partial phi_2′}{partial r} right| ) is known (set to 0 initially) and the coefficients ( c_n, c_n^-, d^0, d_n^+, d_n^- ) are unknown. The system of equations becomes linear and can be solved by Gaussian elimination.
item textbf{Step B:} After obtaining the initial solution, substitute the value of ( left| frac{partial phi_2′}{partial r} right| ) into the equation set and solve for all unknown coefficients, and update the value of ( left| frac{partial phi_2′}{partial r} right| ).
item textbf{Step C:} Calculate the updated unknown coefficients, and compare them with the values obtained in the previous iteration. If the difference between any coefficient is smaller than ( 10^{-3} ), stop the iteration and consider the solution as the final result. Otherwise, continue iterating, updating the value of ( left| frac{partial phi_2′}{partial r} right| ) in each step.
end{itemize}
How can I implement this iterative solution in MATLAB? Specifically, how can I calculate and compare the differences between the unknown coefficients obtained in each step using the initial and updated values of ( left| frac{partial phi_2′}{partial r} right| )? I am working with a nonlinear system of equations, where the term ( left| frac{partial phi_2′}{partial r} right| ) appears in the equations. I need to solve the system iteratively and compare the coefficients calculated using the initial assumption (with ( left| frac{partial phi_2′}{partial r} right| = 0 ) at first) with the updated coefficients obtained after several iterations.
The steps of the process are as follows:
begin{itemize}
item textbf{Step A:} Assume that the value of ( left| frac{partial phi_2′}{partial r} right| ) is known (set to 0 initially) and the coefficients ( c_n, c_n^-, d^0, d_n^+, d_n^- ) are unknown. The system of equations becomes linear and can be solved by Gaussian elimination.
item textbf{Step B:} After obtaining the initial solution, substitute the value of ( left| frac{partial phi_2′}{partial r} right| ) into the equation set and solve for all unknown coefficients, and update the value of ( left| frac{partial phi_2′}{partial r} right| ).
item textbf{Step C:} Calculate the updated unknown coefficients, and compare them with the values obtained in the previous iteration. If the difference between any coefficient is smaller than ( 10^{-3} ), stop the iteration and consider the solution as the final result. Otherwise, continue iterating, updating the value of ( left| frac{partial phi_2′}{partial r} right| ) in each step.
end{itemize}
How can I implement this iterative solution in MATLAB? Specifically, how can I calculate and compare the differences between the unknown coefficients obtained in each step using the initial and updated values of ( left| frac{partial phi_2′}{partial r} right| )? linear, system, equation, iteration MATLAB Answers — New Questions
How can I use table() with a variable number of columns?
I’m making a set of tables from a 4x4x4 array, like so:
T{jj} = table(data(jj,:,1)’,data(jj,:,2)’,data(jj,:,3)’,data(jj,:,4)’,’VariableNames’,colName,’RowNames’,rowName);
The annoying thing is, I have to change this line every time there’s a different number of columns. For example, for 3 columns, the command is:
T{jj} = table(data(jj,:,1)’,data(jj,:,2)’,data(jj,:,3)’,’VariableNames’,colName,’RowNames’,rowName);
I know I could do a switch on the number of columns and have a case for every possible number of columns I might ever have, but is some way around that? The obvious solution of giving it the data as an array doesn’t work if you want named rows and columns:
T{jj} = table(data(jj,:,:),’VariableNames’,colName,’RowNames’,rowName);
Error using table (line 369)
The VariableNames property must contain one name for each variable in the table.
I get the exact same error back if I use slice():
T{jj} = table(slice(data(jj,:,:)),’VariableNames’,colName,’RowNames’,rowName);
But it works fine without row / column names
T{jj} = table(data(jj,:,:));
Am I missing something simple, or is this maybe a design oversight?I’m making a set of tables from a 4x4x4 array, like so:
T{jj} = table(data(jj,:,1)’,data(jj,:,2)’,data(jj,:,3)’,data(jj,:,4)’,’VariableNames’,colName,’RowNames’,rowName);
The annoying thing is, I have to change this line every time there’s a different number of columns. For example, for 3 columns, the command is:
T{jj} = table(data(jj,:,1)’,data(jj,:,2)’,data(jj,:,3)’,’VariableNames’,colName,’RowNames’,rowName);
I know I could do a switch on the number of columns and have a case for every possible number of columns I might ever have, but is some way around that? The obvious solution of giving it the data as an array doesn’t work if you want named rows and columns:
T{jj} = table(data(jj,:,:),’VariableNames’,colName,’RowNames’,rowName);
Error using table (line 369)
The VariableNames property must contain one name for each variable in the table.
I get the exact same error back if I use slice():
T{jj} = table(slice(data(jj,:,:)),’VariableNames’,colName,’RowNames’,rowName);
But it works fine without row / column names
T{jj} = table(data(jj,:,:));
Am I missing something simple, or is this maybe a design oversight? I’m making a set of tables from a 4x4x4 array, like so:
T{jj} = table(data(jj,:,1)’,data(jj,:,2)’,data(jj,:,3)’,data(jj,:,4)’,’VariableNames’,colName,’RowNames’,rowName);
The annoying thing is, I have to change this line every time there’s a different number of columns. For example, for 3 columns, the command is:
T{jj} = table(data(jj,:,1)’,data(jj,:,2)’,data(jj,:,3)’,’VariableNames’,colName,’RowNames’,rowName);
I know I could do a switch on the number of columns and have a case for every possible number of columns I might ever have, but is some way around that? The obvious solution of giving it the data as an array doesn’t work if you want named rows and columns:
T{jj} = table(data(jj,:,:),’VariableNames’,colName,’RowNames’,rowName);
Error using table (line 369)
The VariableNames property must contain one name for each variable in the table.
I get the exact same error back if I use slice():
T{jj} = table(slice(data(jj,:,:)),’VariableNames’,colName,’RowNames’,rowName);
But it works fine without row / column names
T{jj} = table(data(jj,:,:));
Am I missing something simple, or is this maybe a design oversight? table MATLAB Answers — New Questions
How to predefine no.of entites in a entity_batch_creator_block in simevents
I want entity_batch_creator block to take no. of entities from its previous block without explicitly defining it in the dialog box.
That is if for a specific time period no of entities generated are 20 then the entity batch creator takes the batch of 20 entities automatically.I want entity_batch_creator block to take no. of entities from its previous block without explicitly defining it in the dialog box.
That is if for a specific time period no of entities generated are 20 then the entity batch creator takes the batch of 20 entities automatically. I want entity_batch_creator block to take no. of entities from its previous block without explicitly defining it in the dialog box.
That is if for a specific time period no of entities generated are 20 then the entity batch creator takes the batch of 20 entities automatically. entity_batch_creator, aggregation MATLAB Answers — New Questions
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
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
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
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
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
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
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
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
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









