Tag Archives: matlab
Very large output numbers
I have a code which gives me the output of a transfer function with giant values, but I know that they can be reduced to get something smaller but I don’t know how, this would be an example of the output:
(6982830709666455*Kc*s)/140737488355328 or (6383029463564235*s^2)/2251799813685248I have a code which gives me the output of a transfer function with giant values, but I know that they can be reduced to get something smaller but I don’t know how, this would be an example of the output:
(6982830709666455*Kc*s)/140737488355328 or (6383029463564235*s^2)/2251799813685248 I have a code which gives me the output of a transfer function with giant values, but I know that they can be reduced to get something smaller but I don’t know how, this would be an example of the output:
(6982830709666455*Kc*s)/140737488355328 or (6383029463564235*s^2)/2251799813685248 solve, simplify, short MATLAB Answers — New Questions
How do I create a timetable from a file that contains several data columns with associated time columns?
I’ve got files which contain data multiple from multiple sensors. Each sensor has it’s own timestamp. Not all sensors have the same number of values.
Currently I’m splitting the file into several timetables. Then I’ll merge and synchronize the timetables and finally fill the missing values.
Is there a better way to do this, since the original files contain several hundred thousand lines for 50-60 signals?
txtArray= {‘Sig1_Time’ ‘Sig1_Value’ ‘Signal2_Time’ ‘Sig2_Value’ ‘Sig3_Time’ ‘Sig3_Value’;
‘4/28/2020 6:41:56.555 PM’ ‘92.1822814’ ‘4/28/2020 6:41:56.545 PM’ ‘21.2642456’ ‘4/28/2020 6:40:56.545 PM’ ‘1.26’;
‘4/28/2020 6:42:06.655 PM’ ‘92.2822814’ ‘4/28/2020 6:42:06.645 PM’ ‘22.3538671’ ‘4/28/2020 6:50:06.645 PM’ ‘2.35’;
‘4/28/2020 6:42:07.665 PM’ ‘92.1922814’ ‘4/28/2020 6:42:07.655 PM’ ‘22.2642456’ ” ”;
” ” ‘4/28/2020 6:42:08.665 PM’ ‘23.2822436’ ” ”;
” ” ‘4/28/2020 6:42:20.786 PM’ ‘22.2642456’ ” ”;
};
% find columns with timestamps
TimeCols = contains([txtArray(1,:)],’Time’,’IgnoreCase’,true);
% convert times to numerical values
times = datetime([txtArray(2:end,TimeCols)],’InputFormat’,’M/d/yyyy h:m:ss.SSS a’);
NoVars = sum(~TimeCols);
for j=1:NoVars
% create time column in TimeTable
TC = times(:,j);
% create data column in TimeTable
DC = cellfun(@(s) str2double(s),txtArray(:,2*j));
% merge arrays into Timetable, remove invalied (NaT) times
TT(j).tt = array2timetable(DC(~isnat(TC)),’RowTimes’,TC(~isnat(TC)));
end
% merge timetables
for j=1:NoVars
if ~issorted(TT(j).tt);
TT(j).tt=sortrows(TT(j).tt);
end
if j>1
if j==2
Ttable = TT(j-1).tt;
end
% synchronize removes dublicate times
Ttable = synchronize(Ttable,TT(j).tt); % https://mathworks.com/help/matlab/ref/timetable.synchronize.html
Ttable = fillmissing(Ttable,’previous’); % https://mathworks.com/help/matlab/ref/fillmissing.html
end
end
% fill missing values for the first lines which may still be empty
Ttable = fillmissing(Ttable,’next’);
% rename properties
Ttable.Properties.VariableNames = {‘Var1′,’Var2′,’Var3’};I’ve got files which contain data multiple from multiple sensors. Each sensor has it’s own timestamp. Not all sensors have the same number of values.
Currently I’m splitting the file into several timetables. Then I’ll merge and synchronize the timetables and finally fill the missing values.
Is there a better way to do this, since the original files contain several hundred thousand lines for 50-60 signals?
txtArray= {‘Sig1_Time’ ‘Sig1_Value’ ‘Signal2_Time’ ‘Sig2_Value’ ‘Sig3_Time’ ‘Sig3_Value’;
‘4/28/2020 6:41:56.555 PM’ ‘92.1822814’ ‘4/28/2020 6:41:56.545 PM’ ‘21.2642456’ ‘4/28/2020 6:40:56.545 PM’ ‘1.26’;
‘4/28/2020 6:42:06.655 PM’ ‘92.2822814’ ‘4/28/2020 6:42:06.645 PM’ ‘22.3538671’ ‘4/28/2020 6:50:06.645 PM’ ‘2.35’;
‘4/28/2020 6:42:07.665 PM’ ‘92.1922814’ ‘4/28/2020 6:42:07.655 PM’ ‘22.2642456’ ” ”;
” ” ‘4/28/2020 6:42:08.665 PM’ ‘23.2822436’ ” ”;
” ” ‘4/28/2020 6:42:20.786 PM’ ‘22.2642456’ ” ”;
};
% find columns with timestamps
TimeCols = contains([txtArray(1,:)],’Time’,’IgnoreCase’,true);
% convert times to numerical values
times = datetime([txtArray(2:end,TimeCols)],’InputFormat’,’M/d/yyyy h:m:ss.SSS a’);
NoVars = sum(~TimeCols);
for j=1:NoVars
% create time column in TimeTable
TC = times(:,j);
% create data column in TimeTable
DC = cellfun(@(s) str2double(s),txtArray(:,2*j));
% merge arrays into Timetable, remove invalied (NaT) times
TT(j).tt = array2timetable(DC(~isnat(TC)),’RowTimes’,TC(~isnat(TC)));
end
% merge timetables
for j=1:NoVars
if ~issorted(TT(j).tt);
TT(j).tt=sortrows(TT(j).tt);
end
if j>1
if j==2
Ttable = TT(j-1).tt;
end
% synchronize removes dublicate times
Ttable = synchronize(Ttable,TT(j).tt); % https://mathworks.com/help/matlab/ref/timetable.synchronize.html
Ttable = fillmissing(Ttable,’previous’); % https://mathworks.com/help/matlab/ref/fillmissing.html
end
end
% fill missing values for the first lines which may still be empty
Ttable = fillmissing(Ttable,’next’);
% rename properties
Ttable.Properties.VariableNames = {‘Var1′,’Var2′,’Var3’}; I’ve got files which contain data multiple from multiple sensors. Each sensor has it’s own timestamp. Not all sensors have the same number of values.
Currently I’m splitting the file into several timetables. Then I’ll merge and synchronize the timetables and finally fill the missing values.
Is there a better way to do this, since the original files contain several hundred thousand lines for 50-60 signals?
txtArray= {‘Sig1_Time’ ‘Sig1_Value’ ‘Signal2_Time’ ‘Sig2_Value’ ‘Sig3_Time’ ‘Sig3_Value’;
‘4/28/2020 6:41:56.555 PM’ ‘92.1822814’ ‘4/28/2020 6:41:56.545 PM’ ‘21.2642456’ ‘4/28/2020 6:40:56.545 PM’ ‘1.26’;
‘4/28/2020 6:42:06.655 PM’ ‘92.2822814’ ‘4/28/2020 6:42:06.645 PM’ ‘22.3538671’ ‘4/28/2020 6:50:06.645 PM’ ‘2.35’;
‘4/28/2020 6:42:07.665 PM’ ‘92.1922814’ ‘4/28/2020 6:42:07.655 PM’ ‘22.2642456’ ” ”;
” ” ‘4/28/2020 6:42:08.665 PM’ ‘23.2822436’ ” ”;
” ” ‘4/28/2020 6:42:20.786 PM’ ‘22.2642456’ ” ”;
};
% find columns with timestamps
TimeCols = contains([txtArray(1,:)],’Time’,’IgnoreCase’,true);
% convert times to numerical values
times = datetime([txtArray(2:end,TimeCols)],’InputFormat’,’M/d/yyyy h:m:ss.SSS a’);
NoVars = sum(~TimeCols);
for j=1:NoVars
% create time column in TimeTable
TC = times(:,j);
% create data column in TimeTable
DC = cellfun(@(s) str2double(s),txtArray(:,2*j));
% merge arrays into Timetable, remove invalied (NaT) times
TT(j).tt = array2timetable(DC(~isnat(TC)),’RowTimes’,TC(~isnat(TC)));
end
% merge timetables
for j=1:NoVars
if ~issorted(TT(j).tt);
TT(j).tt=sortrows(TT(j).tt);
end
if j>1
if j==2
Ttable = TT(j-1).tt;
end
% synchronize removes dublicate times
Ttable = synchronize(Ttable,TT(j).tt); % https://mathworks.com/help/matlab/ref/timetable.synchronize.html
Ttable = fillmissing(Ttable,’previous’); % https://mathworks.com/help/matlab/ref/fillmissing.html
end
end
% fill missing values for the first lines which may still be empty
Ttable = fillmissing(Ttable,’next’);
% rename properties
Ttable.Properties.VariableNames = {‘Var1′,’Var2′,’Var3’}; timetable, data import, array2timetable, multiple time columns MATLAB Answers — New Questions
How to fill the space between two surfaces?
If f1(x,y)≤z≤f2(x,y), how to draw the range of z? If the upper and lower limits of z are described by separate functions, how to plot the range of the z function in the direction of the z-axis instead of two surfaces?
x=-5:0.1:5;
y=-5:0.1:5;
[XX,YY]=meshgrid(x,y);
for m=1:101
for n=1:101
z1(m,n)=x(m)^2+y(n)^2;
z2(m,n)=3*x(m)^3+y(n)^2+1;
plot3([XX(m,n) XX(m,n)],[YY(m,n) YY(m,n)],[z1(m,n) z2(m,n)])
hold on
end
end
hold on
The code to draw only 2 surfaces is given here.
x=-5:0.1:5;
y=-5:0.1:5;
for m=1:101
for n=1:101
z1(m,n)=x(m)^2+y(n)^2;
z2(m,n)=3*x(m)^3+y(n)^2+1;
end
end
surf(x,y,z1,"EdgeColor","none")
hold on
surf(x,y,z2,"EdgeColor","none")If f1(x,y)≤z≤f2(x,y), how to draw the range of z? If the upper and lower limits of z are described by separate functions, how to plot the range of the z function in the direction of the z-axis instead of two surfaces?
x=-5:0.1:5;
y=-5:0.1:5;
[XX,YY]=meshgrid(x,y);
for m=1:101
for n=1:101
z1(m,n)=x(m)^2+y(n)^2;
z2(m,n)=3*x(m)^3+y(n)^2+1;
plot3([XX(m,n) XX(m,n)],[YY(m,n) YY(m,n)],[z1(m,n) z2(m,n)])
hold on
end
end
hold on
The code to draw only 2 surfaces is given here.
x=-5:0.1:5;
y=-5:0.1:5;
for m=1:101
for n=1:101
z1(m,n)=x(m)^2+y(n)^2;
z2(m,n)=3*x(m)^3+y(n)^2+1;
end
end
surf(x,y,z1,"EdgeColor","none")
hold on
surf(x,y,z2,"EdgeColor","none") If f1(x,y)≤z≤f2(x,y), how to draw the range of z? If the upper and lower limits of z are described by separate functions, how to plot the range of the z function in the direction of the z-axis instead of two surfaces?
x=-5:0.1:5;
y=-5:0.1:5;
[XX,YY]=meshgrid(x,y);
for m=1:101
for n=1:101
z1(m,n)=x(m)^2+y(n)^2;
z2(m,n)=3*x(m)^3+y(n)^2+1;
plot3([XX(m,n) XX(m,n)],[YY(m,n) YY(m,n)],[z1(m,n) z2(m,n)])
hold on
end
end
hold on
The code to draw only 2 surfaces is given here.
x=-5:0.1:5;
y=-5:0.1:5;
for m=1:101
for n=1:101
z1(m,n)=x(m)^2+y(n)^2;
z2(m,n)=3*x(m)^3+y(n)^2+1;
end
end
surf(x,y,z1,"EdgeColor","none")
hold on
surf(x,y,z2,"EdgeColor","none") filling surface space, three-dimensional drawing MATLAB Answers — New Questions
Why is my table getting all the same values when it shouldn’t?
For some reason my code to automatically fill in a table is running but it’s outputting the same value for all the columns. Which it shouldn’t be getting and I can’t figure out why.
All necessary codes to run this properly are attached and should be run as follows to get a proper output: Lab2PartA -> Select "Example1.txt" when prompted -> DeranAutoTableAttempt
Here is my code:
% Set the value of R as depicted in Table 1 and set C = 1.2 ml/mmHg and run the model
R = [0.50, 0.75, 1, 1.25, 1.5, 1.75, 2];
%% Basline (a1_b) of R is 1.2
a1_b = 1.2;
%Prep to run simulink
C = 1.2;
%Prep Table 1
k = 1;
j = 1 + height(Table1);
R = 0.5:0.25:2;
Z = zeros(size(R));
Table1 = table(R(:),Z(:),Z(:),Z(:),Z(:),…
‘VariableNames’,{‘R (mmHg*s/ml)’ ‘Pressure Maximum (mmHg)’ ‘Pressure Minimum (mmHg)’ ‘Presure Mean (mmHg)’ ‘Pulse Pressure (max-min) (mmHg)’});
while k ~= j
fprintf("R = %d", R(k))
sim(‘ArterialModel2E’)
run MinMax.m;
MinMaxTab = [maxPModel; minPModel; meanPModel];
Table1{k,2} = MinMaxTab(1,1);
Table1{k,3} = MinMaxTab(2,1);
Table1{k,4} = MinMaxTab(3,1);
Table1{k,5} = Table1{k,3}-Table1{k,2};
k = k+1;
end
Table1
% Now set C equal to the value in Table 2 and set R = 1 ml/mmHg
C = [0.6, 0.9, 1.2, 1.5, 1.8, 2.1, 2.4];
% Baseline (a2_b) of C is 1.2
a2_b = 1.2;
% Prep to run simulink
R = 1;
% Prep Table 2
k = 1;
j = 1 + height(Table1);
C = 0.6:0.3:2.4;
Z = zeros(size(C));
Table2 = table(C(:),Z(:),Z(:),Z(:),Z(:),…
‘VariableNames’,{‘C (mmHg*s/ml)’ ‘Pressure Maximum (mmHg)’ ‘Pressure Minimum (mmHg)’ ‘Presure Mean (mmHg)’ ‘Pulse Pressure (max-min) (mmHg)’});
while k ~= j
fprintf("C = %d", C(k))
sim(‘ArterialModel2E’)
run MinMax.m;
MinMaxTab = [maxPModel; minPModel; meanPModel];
Table2{k,2} = MinMaxTab(1,1);
Table2{k,3} = MinMaxTab(2,1);
Table2{k,4} = MinMaxTab(3,1);
Table2{k,5} = Table2{k,3}-Table2{k,2};
k = k+1;
end
Table2
Table 1 results should be:
Table 2 should be:For some reason my code to automatically fill in a table is running but it’s outputting the same value for all the columns. Which it shouldn’t be getting and I can’t figure out why.
All necessary codes to run this properly are attached and should be run as follows to get a proper output: Lab2PartA -> Select "Example1.txt" when prompted -> DeranAutoTableAttempt
Here is my code:
% Set the value of R as depicted in Table 1 and set C = 1.2 ml/mmHg and run the model
R = [0.50, 0.75, 1, 1.25, 1.5, 1.75, 2];
%% Basline (a1_b) of R is 1.2
a1_b = 1.2;
%Prep to run simulink
C = 1.2;
%Prep Table 1
k = 1;
j = 1 + height(Table1);
R = 0.5:0.25:2;
Z = zeros(size(R));
Table1 = table(R(:),Z(:),Z(:),Z(:),Z(:),…
‘VariableNames’,{‘R (mmHg*s/ml)’ ‘Pressure Maximum (mmHg)’ ‘Pressure Minimum (mmHg)’ ‘Presure Mean (mmHg)’ ‘Pulse Pressure (max-min) (mmHg)’});
while k ~= j
fprintf("R = %d", R(k))
sim(‘ArterialModel2E’)
run MinMax.m;
MinMaxTab = [maxPModel; minPModel; meanPModel];
Table1{k,2} = MinMaxTab(1,1);
Table1{k,3} = MinMaxTab(2,1);
Table1{k,4} = MinMaxTab(3,1);
Table1{k,5} = Table1{k,3}-Table1{k,2};
k = k+1;
end
Table1
% Now set C equal to the value in Table 2 and set R = 1 ml/mmHg
C = [0.6, 0.9, 1.2, 1.5, 1.8, 2.1, 2.4];
% Baseline (a2_b) of C is 1.2
a2_b = 1.2;
% Prep to run simulink
R = 1;
% Prep Table 2
k = 1;
j = 1 + height(Table1);
C = 0.6:0.3:2.4;
Z = zeros(size(C));
Table2 = table(C(:),Z(:),Z(:),Z(:),Z(:),…
‘VariableNames’,{‘C (mmHg*s/ml)’ ‘Pressure Maximum (mmHg)’ ‘Pressure Minimum (mmHg)’ ‘Presure Mean (mmHg)’ ‘Pulse Pressure (max-min) (mmHg)’});
while k ~= j
fprintf("C = %d", C(k))
sim(‘ArterialModel2E’)
run MinMax.m;
MinMaxTab = [maxPModel; minPModel; meanPModel];
Table2{k,2} = MinMaxTab(1,1);
Table2{k,3} = MinMaxTab(2,1);
Table2{k,4} = MinMaxTab(3,1);
Table2{k,5} = Table2{k,3}-Table2{k,2};
k = k+1;
end
Table2
Table 1 results should be:
Table 2 should be: For some reason my code to automatically fill in a table is running but it’s outputting the same value for all the columns. Which it shouldn’t be getting and I can’t figure out why.
All necessary codes to run this properly are attached and should be run as follows to get a proper output: Lab2PartA -> Select "Example1.txt" when prompted -> DeranAutoTableAttempt
Here is my code:
% Set the value of R as depicted in Table 1 and set C = 1.2 ml/mmHg and run the model
R = [0.50, 0.75, 1, 1.25, 1.5, 1.75, 2];
%% Basline (a1_b) of R is 1.2
a1_b = 1.2;
%Prep to run simulink
C = 1.2;
%Prep Table 1
k = 1;
j = 1 + height(Table1);
R = 0.5:0.25:2;
Z = zeros(size(R));
Table1 = table(R(:),Z(:),Z(:),Z(:),Z(:),…
‘VariableNames’,{‘R (mmHg*s/ml)’ ‘Pressure Maximum (mmHg)’ ‘Pressure Minimum (mmHg)’ ‘Presure Mean (mmHg)’ ‘Pulse Pressure (max-min) (mmHg)’});
while k ~= j
fprintf("R = %d", R(k))
sim(‘ArterialModel2E’)
run MinMax.m;
MinMaxTab = [maxPModel; minPModel; meanPModel];
Table1{k,2} = MinMaxTab(1,1);
Table1{k,3} = MinMaxTab(2,1);
Table1{k,4} = MinMaxTab(3,1);
Table1{k,5} = Table1{k,3}-Table1{k,2};
k = k+1;
end
Table1
% Now set C equal to the value in Table 2 and set R = 1 ml/mmHg
C = [0.6, 0.9, 1.2, 1.5, 1.8, 2.1, 2.4];
% Baseline (a2_b) of C is 1.2
a2_b = 1.2;
% Prep to run simulink
R = 1;
% Prep Table 2
k = 1;
j = 1 + height(Table1);
C = 0.6:0.3:2.4;
Z = zeros(size(C));
Table2 = table(C(:),Z(:),Z(:),Z(:),Z(:),…
‘VariableNames’,{‘C (mmHg*s/ml)’ ‘Pressure Maximum (mmHg)’ ‘Pressure Minimum (mmHg)’ ‘Presure Mean (mmHg)’ ‘Pulse Pressure (max-min) (mmHg)’});
while k ~= j
fprintf("C = %d", C(k))
sim(‘ArterialModel2E’)
run MinMax.m;
MinMaxTab = [maxPModel; minPModel; meanPModel];
Table2{k,2} = MinMaxTab(1,1);
Table2{k,3} = MinMaxTab(2,1);
Table2{k,4} = MinMaxTab(3,1);
Table2{k,5} = Table2{k,3}-Table2{k,2};
k = k+1;
end
Table2
Table 1 results should be:
Table 2 should be: simulink, table, while loop MATLAB Answers — New Questions
Compiling a single file for multiple Sfun
I want multiple sfun blocks to use a common C file in Simulink, but I get an error. Is this kind of usage possible ?I want multiple sfun blocks to use a common C file in Simulink, but I get an error. Is this kind of usage possible ? I want multiple sfun blocks to use a common C file in Simulink, but I get an error. Is this kind of usage possible ? simulink, embedded coder, mex compiler MATLAB Answers — New Questions
Error during training: Invalid training data. Y must be a vector of categorical responses.
am using single image as input for cnn for segmentation above error am getting please help me to resolveam using single image as input for cnn for segmentation above error am getting please help me to resolve am using single image as input for cnn for segmentation above error am getting please help me to resolve help me in this error MATLAB Answers — New Questions
Why am I unable to start the Network License Manager on Linux?
Why do I receive one of the following errors when I try to launch the Network License Manager on Linux?
./lmgrd: Command not found.
/lib64/ld-lsb-x86-64.so.3: bad ELF interpreter: No such file or directory
MLM: can’t initialize: Invalid license file syntax. (-2,40027) EXITING DUE TO SIGNAL 52 Exit reason 20
eval: 1: /var/tmp/lm_TMW.ld: not found
Waiting 300 secs for MATLAB vendor daemon to come up . . .
Type your interrupt character (usually CTRL-C) to quit.
Time = 3 secs : still waiting . . .
/usr/local/MATLAB/R2024a/etc/glnxa64/lmhostid: not found
Error: Your hostname matches the hostname on a SERVER line in
your license file but the lmhostid in that line does not.
Your local lmhostid(s) are:
Your hostname is: licserver1.support.mathworks.com
The SERVER line in question is:
———————————————–
SERVER licserver1.support.mathworks.com 001122DDEE99 27000
———————————————–
Please stop, fix the problem, and try again . . .Why do I receive one of the following errors when I try to launch the Network License Manager on Linux?
./lmgrd: Command not found.
/lib64/ld-lsb-x86-64.so.3: bad ELF interpreter: No such file or directory
MLM: can’t initialize: Invalid license file syntax. (-2,40027) EXITING DUE TO SIGNAL 52 Exit reason 20
eval: 1: /var/tmp/lm_TMW.ld: not found
Waiting 300 secs for MATLAB vendor daemon to come up . . .
Type your interrupt character (usually CTRL-C) to quit.
Time = 3 secs : still waiting . . .
/usr/local/MATLAB/R2024a/etc/glnxa64/lmhostid: not found
Error: Your hostname matches the hostname on a SERVER line in
your license file but the lmhostid in that line does not.
Your local lmhostid(s) are:
Your hostname is: licserver1.support.mathworks.com
The SERVER line in question is:
———————————————–
SERVER licserver1.support.mathworks.com 001122DDEE99 27000
———————————————–
Please stop, fix the problem, and try again . . . Why do I receive one of the following errors when I try to launch the Network License Manager on Linux?
./lmgrd: Command not found.
/lib64/ld-lsb-x86-64.so.3: bad ELF interpreter: No such file or directory
MLM: can’t initialize: Invalid license file syntax. (-2,40027) EXITING DUE TO SIGNAL 52 Exit reason 20
eval: 1: /var/tmp/lm_TMW.ld: not found
Waiting 300 secs for MATLAB vendor daemon to come up . . .
Type your interrupt character (usually CTRL-C) to quit.
Time = 3 secs : still waiting . . .
/usr/local/MATLAB/R2024a/etc/glnxa64/lmhostid: not found
Error: Your hostname matches the hostname on a SERVER line in
your license file but the lmhostid in that line does not.
Your local lmhostid(s) are:
Your hostname is: licserver1.support.mathworks.com
The SERVER line in question is:
———————————————–
SERVER licserver1.support.mathworks.com 001122DDEE99 27000
———————————————–
Please stop, fix the problem, and try again . . . MATLAB Answers — New Questions
Swarmchart maximum diplay for shapley?
I will draw a shapey model with Swarmchart. When I draw it, it shows a maximum of 10 predictors on the right axis. How can I increase it to 20?
Example;
swarmchart(explainer,’Class’,1)I will draw a shapey model with Swarmchart. When I draw it, it shows a maximum of 10 predictors on the right axis. How can I increase it to 20?
Example;
swarmchart(explainer,’Class’,1) I will draw a shapey model with Swarmchart. When I draw it, it shows a maximum of 10 predictors on the right axis. How can I increase it to 20?
Example;
swarmchart(explainer,’Class’,1) swarmchart, shapley MATLAB Answers — New Questions
I have a ECG signal along with a respiration signal, I need to filter it to separate the ECG and the Respiration signals. Also, extract the QRS complex from the filtered ECG.
I have a ECG signal along with a respiration signal, I need to filter it to separate the ECG and the Respiration signals. I can apply a FIR/IIR filter or any appropriate method. Also, i need to extract the QRS complex from the filtered ECG. I have attachted the code that I use to filter the signal extract the QRS complex but the results are not satisfying.I have a ECG signal along with a respiration signal, I need to filter it to separate the ECG and the Respiration signals. I can apply a FIR/IIR filter or any appropriate method. Also, i need to extract the QRS complex from the filtered ECG. I have attachted the code that I use to filter the signal extract the QRS complex but the results are not satisfying. I have a ECG signal along with a respiration signal, I need to filter it to separate the ECG and the Respiration signals. I can apply a FIR/IIR filter or any appropriate method. Also, i need to extract the QRS complex from the filtered ECG. I have attachted the code that I use to filter the signal extract the QRS complex but the results are not satisfying. filter, ecg, qrs complex MATLAB Answers — New Questions
Shortcut set for “evaluate selection” not working / responding in Matlab 2022b Update 4
I got o Preferences > Keyboard > Shortcuts and modify the shortcut for ‘Evaluate Selection’ to e.g., command + <.
However, after accepting changes, selecting code in the editor or command window and pressing command + < (or any other attempted shortcut) won’t work.
Any help would be welcome, thank you.I got o Preferences > Keyboard > Shortcuts and modify the shortcut for ‘Evaluate Selection’ to e.g., command + <.
However, after accepting changes, selecting code in the editor or command window and pressing command + < (or any other attempted shortcut) won’t work.
Any help would be welcome, thank you. I got o Preferences > Keyboard > Shortcuts and modify the shortcut for ‘Evaluate Selection’ to e.g., command + <.
However, after accepting changes, selecting code in the editor or command window and pressing command + < (or any other attempted shortcut) won’t work.
Any help would be welcome, thank you. shortcuts, evaluate, selection MATLAB Answers — New Questions
n-way anova with 2 seperate group and 2 seperate data
Hi
Need a help with n-way anova. I’ve got exel table where A and B git values 0 – user incorrect answer and 1 – correct answer, and the labels to them like below:
A = [1 0 1 0 0 1 0]
B = [1 1 0 0 1 1 1]
LabelsA = [red blue white white white blue red]
LabelsB = [high medium medium high low low high]
And now, using the data I need to use anova to create table and multicompare of the stats to see: probability of the case A. Probability of the case 2 and probability A*B.
Additionally i need to draw the all variances probability like: x1 = red x2 = high, x1 = red x2 = medium … x1 = white, x2 = low. so 9 pairs
Tried anova2 but i cannot do all of the variances with groups. Tried anovan but i can input in there only wektor of the data
Would be grateful for any tip.Hi
Need a help with n-way anova. I’ve got exel table where A and B git values 0 – user incorrect answer and 1 – correct answer, and the labels to them like below:
A = [1 0 1 0 0 1 0]
B = [1 1 0 0 1 1 1]
LabelsA = [red blue white white white blue red]
LabelsB = [high medium medium high low low high]
And now, using the data I need to use anova to create table and multicompare of the stats to see: probability of the case A. Probability of the case 2 and probability A*B.
Additionally i need to draw the all variances probability like: x1 = red x2 = high, x1 = red x2 = medium … x1 = white, x2 = low. so 9 pairs
Tried anova2 but i cannot do all of the variances with groups. Tried anovan but i can input in there only wektor of the data
Would be grateful for any tip. Hi
Need a help with n-way anova. I’ve got exel table where A and B git values 0 – user incorrect answer and 1 – correct answer, and the labels to them like below:
A = [1 0 1 0 0 1 0]
B = [1 1 0 0 1 1 1]
LabelsA = [red blue white white white blue red]
LabelsB = [high medium medium high low low high]
And now, using the data I need to use anova to create table and multicompare of the stats to see: probability of the case A. Probability of the case 2 and probability A*B.
Additionally i need to draw the all variances probability like: x1 = red x2 = high, x1 = red x2 = medium … x1 = white, x2 = low. so 9 pairs
Tried anova2 but i cannot do all of the variances with groups. Tried anovan but i can input in there only wektor of the data
Would be grateful for any tip. anova, n-way anova, statistics, probability, ranova, matlab, anova2 MATLAB Answers — New Questions
Unable to get a continuous curvature for my nozzle contour
Greetings everyone, I am trying to fit a Bezier Curve as shown in the paper provide(fig1), but I am unable to get the desired plot(fig 2 and fig3). I have attached the codes as well as the paper and plot. Any help on this is highly appreciated!.
PS: The inflection point is the last point on xarc, i.e, xarc(end) and Nozzle_WithCircARc.m is the main file. It would be better to run the file cell by cell.
%function Nozzle_WithCircARc(G,Me,n,display)
%% Initialize datapoint matrices
clearvars;close all;clc;
G=1.4;
Me = 2.0;
n = 53; % speed index from pucketts paper
display = 0;
Km = zeros(n,n); % K- vlaues (Constant along right running characteristic lines)
Kp = zeros(n,n); % K+ vlaues (Constant along left running characteristic lines)
Theta = zeros(n,n); % Flow angles relative to the horizontal
Mu = zeros(n,n); % Mach angles
M = zeros(n,n); % Mach Numbers
x = zeros(n,n); % x-coordinates
y = zeros(n,n); % y-coordinates
%% Generate the convergent portion of a nozzle
% The inlet height/area and exit height/area(divergent) are same
% Therefore we have same A/A* = 1.6875
% Corresponding to Mach = 0.3722
%% Find NuMax (maximum expansion angle)
[~, NuMax, ~] = PMF(G,Me,0,0);
ThetaMax = NuMax/2;
%%
%ThetaMax0 = (1.0/1.687)^(2/9) * (NuMax/2);
%% Define some flow parameters of originating characteristic lines
dT = ThetaMax/n;
%no_ref = (ThetaMax – ThetaMax_ref)/dT;
ThetaArc(:,1) = (0:dT:ThetaMax);
NuArc = ThetaArc;
KmArc = ThetaArc + NuArc;
[~, ~, MuArc(:,1)] = PMF(G,0,NuArc(:,1),0);
%% Coordinates of wall along curve from throat
y0 = 1; % Define throat half-height
ThroatCurveRadius = 1.5*y0; % Radius of curvature just downstream of the throat
% for larger factors, ywall deviates from A/A* preferred value is 1.1
%L_e = 1.1 * y0 * sind(ThetaMax);
[xarc, yarc] = Arc(ThroatCurveRadius,ThetaArc); % Finds x- and y-coordinates for given theta-values
yarc(:,1) = yarc(:,1) + y0; % Defines offset due to arc being above horizontal
%% Fill in missing datapoint info along first C+ line
% First centerline datapoint done manually
Km(:,1) = KmArc(2:length(KmArc),1);
Theta(:,1) = ThetaArc(2:length(KmArc),1);
Nu(:,1) = Theta(:,1);
Kp(:,1) = Theta(:,1)-Nu(:,1);
M(1,1) = 1.0001;
Nu(1,1) = 0;
Mu(1,1) = 90;
y(1,1) = 0;
x(1,1) = xarc(2,1) + (y(1,1) – yarc(2,1))/tand((ThetaArc(2,1) – MuArc(2,1) – MuArc(2,1))/2);
% Finds the information at interior nodes along first C+ line
for i=2:n
[M(i,1), Nu(i,1), Mu(i,1)] = PMF(G,0,Nu(i,1),0);
s1 = tand((ThetaArc(i+1,1) – MuArc(i+1,1) + Theta(i,1) – Mu(i,1))/2);
s2 = tand((Theta(i-1,1) + Mu(i-1,1) + Theta(i,1) + Mu(i,1))/2);
x(i,1) = ((y(i-1,1)-x(i-1,1)*s2)-(yarc(i+1,1)-xarc(i+1,1)*s1))/(s1-s2);
y(i,1) = y(i-1,1) + (x(i,1)-x(i-1,1))*s2;
end
%% Find flow properties at remaining interior nodes
for j=2:n;
for i=1:n+1-j;
Km(i,j) = Km(i+1,j-1);
if i==1;
Theta(i,j) = 0;
Kp(i,j) = -Km(i,j);
Nu(i,j) = Km(i,j);
[M(i,j), Nu(i,j), Mu(i,j)] = PMF(G,0,Nu(i,j),0);
s1 = tand((Theta(i+1,j-1)-Mu(i+1,j-1)+Theta(i,j)-Mu(i,j))/2);
x(i,j) = x(i+1,j-1) – y(i+1,j-1)/s1;
y(i,j) = 0;
else
Kp(i,j) = Kp(i-1,j);
Theta(i,j) = (Km(i,j)+Kp(i,j))/2;
Nu(i,j) = (Km(i,j)-Kp(i,j))/2;
[M(i,j), Nu(i,j), Mu(i,j)] = PMF(G,0,Nu(i,j),0);
s1 = tand((Theta(i+1,j-1)-Mu(i+1,j-1)+Theta(i,j)-Mu(i,j))/2);
s2 = tand((Theta(i-1,j)+Mu(i-1,j)+Theta(i,j)+Mu(i,j))/2);
x(i,j) = ((y(i-1,j)-x(i-1,j)*s2)-(y(i+1,j-1)-x(i+1,j-1)*s1))/(s1-s2);
y(i,j) = y(i-1,j) + (x(i,j)-x(i-1,j))*s2;
end
end
end
%% Find wall node information
xwall = zeros(2*n,1);
ywall = xwall;
ThetaWall = ywall;
xwall(1:n,1) = xarc(2:length(xarc),1);
ywall(1:n,1) = yarc(2:length(xarc),1);
ThetaWall(1:n,1) = ThetaArc(2:length(xarc),1);
for i=1:n-1
ThetaWall(n+i,1) = ThetaWall(n-i,1); % criteria for stopping the reflection from the wall
end
%% Location of wall points
for i=1:n
s1 = tand((ThetaWall(n+i-1,1) + ThetaWall(n+i,1))/2);
s2 = tand(Theta(n+1-i,i)+Mu(n+1-i,i));
xwall(n+i,1) = ((y(n+1-i,i)-x(n+1-i,i)*s2)-(ywall(n+i-1,1)-xwall(n+i-1,1)*s1))/(s1-s2);
ywall(n+i,1) = ywall(n+i-1,1) + (xwall(n+i,1)-xwall(n+i-1,1))*s1;
end
%% Provide wall geometry to user
assignin(‘caller’,’xwall’,xwall)
assignin(‘caller’,’ywall’,ywall)
assignin(‘caller’,’Coords’,[xwall ywall])
%% Generate the convergent portion of nozzle
H_in = ywall(end);
L_e = (xwall(end)*(1.0/3.0));
[xconv,yconv] = Convergent_new_3rd(y0,H_in,L_e,n);
%%
% Draw contour and characteristic web
if display == 1
plot(xwall,ywall,’-‘)
axis equal
axis([0 ceil(xwall(length(xwall),1)) 0 ceil(ywall(length(ywall),1))])
hold on
plot(xarc,yarc,’k-‘)
for i=1:n-1
plot(x(1:n+1-i,i),y(1:n+1-i,i))
end
for i=1:n
plot([xarc(i,1) x(i,1)],[yarc(i,1) y(i,1)])
plot([x(n+1-i,i) xwall(i+n,1)],[y(n+1-i,i) ywall(i+n,1)])
end
for c=1:n
for r=2:n+1-c
plot([x(c,r) x(c+1,r-1)],[y(c,r) y(c+1,r-1)])
end
end
%hold on
%contourf(x, y, M, 20, ‘LineColor’, ‘none’); % Draw Mach number contours
%colorbar;
xlabel(‘Length [x/y0]’)
ylabel(‘Height [y/y0]’)
end
%% Non-scaled/non-dimensionalized plot
figure (1)
plot(xwall,ywall,’.b’)
title("Non dimensionalized plot")
axis equal
hold on
plot(xarc,yarc,’-‘)
hold on
plot(xconv,yconv,’-‘)
xlabel(‘xwall’)
ylabel(‘ywall’)
axis equal
%%
%{
plot(xwall,ThetaWall)
xlabel(‘xwall’)
ylabel(‘ThetaWall’)
%%
x1 = linspace(min(xwall),max(xwall),1000);
%y1 = spline(xw,yw,x1);
y1 = interp1(xwall,ywall,x1,’spline’);
figure;
title(‘Subplot 2: Cubic spline interpolation’)
plot(x1,y1,’r’)
%}
%%
%{
for i = 1:length(M)
M_centerline(i) = M(1,i);
end
for i =1:length(x)
x_axial(i) = x(1,i);
end
plot(x_axial’, Mcenterline’,’r’,’LineWidth’,2)
%}
%% Find the scaling factor
Mexit = Me;
[~,~,~,~,area] = flowisentropic(G,Mexit);
Hexit = 11.2798; %mm
Full_Throat_height = Hexit/area;
half_yt = Full_Throat_height/2.0;
%% Scaling of factors
xarc = half_yt.*xarc;
yarc = half_yt.*yarc;
xwall = half_yt.*xwall;
ywall = half_yt.*ywall;
xconv = half_yt.*xconv;
yconv = half_yt.*yconv;
%% Scaled up coordinates in mm
%{
title("Dimensionalized Plot")
plot(xwall,ywall,’-‘)
hold on
plot(xarc,yarc,’-‘)
hold on
plot(xconv,yconv,’-‘)
xlabel(‘xwall’)
ylabel(‘ywall’)
axis equal
%}
%% Combine Coordinates
% Combine xconv and xwall
coords_new_x = [xconv; xwall];
coords_new_y = [yconv; ywall];
%%
figure (2)
hold on;
plot(xconv, yconv, ‘.b’, ‘LineWidth’, 1.5) % Convergent section
plot(xwall, ywall, ‘.r’, ‘LineWidth’, 1.5) % Wall section
plot(xarc,yarc,’.g’,’LineWidth’,1.5) % arc
plot(xconv, -1.*yconv, ‘.b’, ‘LineWidth’, 1.5) % Convergent section
plot(xwall, -1.*ywall, ‘.r’, ‘LineWidth’, 1.5) % Wall section
plot(xarc,-1.*yarc,’.g’,’LineWidth’,1.5) % arc
xlabel(‘x [mm]’);
ylabel(‘y [mm]’);
title(‘Scaled up CD nozzle’);
legend(‘Convergent Section’, ‘Straightening Section’, ‘Initial Expansion (Arc)’);
grid on;
axis equal
%% Export coordinates
x1 = linspace(min(coords_new_x ),max(coords_new_x),1000);
%y1 = spline(xw,yw,x1);
y1 = interp1(coords_new_x,coords_new_y,x1,’spline’);
x2 = x1′;
y2 = y1′;
%figure;
%plot(x1,y1,’r’)
%writematrix(x2,’Spline.xlsx’,’Sheet’,1,’Range’,’A1′);
%writematrix(y2,’Spline.xlsx’,’Sheet’,1,’Range’,’B1′);
%%
%{
plot(x2,y2)
%%
plot(xwall,ywall,’-‘)
axis equal
axis([0 ceil(xwall(length(xwall),1)) 0 ceil(ywall(length(ywall),1))])
hold on
plot(xarc,yarc,’k-‘)
%}
%% Coordinates of wall
%{
writematrix(coords_new_x,’coordinates.xlsx’,’Sheet’,1,’Range’,’A1′);
writematrix(coords_new_y,’coordinates.xlsx’,’Sheet’,1,’Range’,’B1′);
%}
%%
%{
plot(x2,y2,’-k’)
hold on
plot(x2,-1.*(y2),’-r’)
grid on
title("CD Nozzle using a Circular Arc")
axis equal
%}
%% Analyze the discontinuity
% Find second-order derivative of wall contour
dy2_dx2 = zeros(size(xwall));
% Loop over all points except the last two
for i = 1:length(xwall)-2
% Calculate the second-order derivative using the forward difference formula
dy2_dx2(i) = (ywall(i+2) – 2*ywall(i+1) + ywall(i)) / (xwall(i+1) – xwall(i))^2;
end
dy2_dx2(end-1:end) = NaN; % last two points
%% Bezier Curve
threshold = 0.05; % Define a threshold for discontinuity detection (can be adjusted)
discontinuities = find(abs(diff(dy2_dx2)) > threshold);
%%
if ~isempty(discontinuities)
for idx = 1:length(discontinuities)
point_idx = discontinuities(idx); % Index of discontinuity
% Skip a few points around the discontinuity
region_start = max(1, point_idx – 2); % Upstream region
region_end = min(length(xwall), point_idx + 2); % Downstream region
% Use Bézier curve fitting only in this region to smooth the discontinuity
P0 = [xwall(region_start), ywall(region_start)]; % Start point
P1 = [xwall(point_idx), ywall(point_idx)]; % Control point (inflection/discontinuity)
P2 = [xwall(region_end), ywall(region_end)]; % End point
% Parameter t varies between 0 and 1 to interpolate the Bézier curve
t = linspace(0, 1, region_end – region_start + 1)’;
xwall(region_start:region_end) = (1-t).^2 * P0(1) + 2*(1-t).*t * P1(1) + t.^2 * P2(1);
ywall(region_start:region_end) = (1-t).^2 * P0(2) + 2*(1-t).*t * P1(2) + t.^2 * P2(2);
end
end
%%
plot(xwall,ywall,’.b’)
axis equal
%% Checking for continuous second order derivative of wall contour
cont_dy2_dx2 = zeros(size(xwall));
% Loop over all points except the last two (since forward difference needs i+2)
for i = 1:length(xwall)-2
% Calculate the second-order derivative using the forward difference formula
cont_dy2_dx2(i) = (ywall(i+2) – 2*ywall(i+1) + ywall(i)) / (xwall(i+1) – xwall(i))^2;
end
cont_dy2_dx2(end-1:end) = NaN;
plot(xwall./xwall(end), dy2_dx2)Greetings everyone, I am trying to fit a Bezier Curve as shown in the paper provide(fig1), but I am unable to get the desired plot(fig 2 and fig3). I have attached the codes as well as the paper and plot. Any help on this is highly appreciated!.
PS: The inflection point is the last point on xarc, i.e, xarc(end) and Nozzle_WithCircARc.m is the main file. It would be better to run the file cell by cell.
%function Nozzle_WithCircARc(G,Me,n,display)
%% Initialize datapoint matrices
clearvars;close all;clc;
G=1.4;
Me = 2.0;
n = 53; % speed index from pucketts paper
display = 0;
Km = zeros(n,n); % K- vlaues (Constant along right running characteristic lines)
Kp = zeros(n,n); % K+ vlaues (Constant along left running characteristic lines)
Theta = zeros(n,n); % Flow angles relative to the horizontal
Mu = zeros(n,n); % Mach angles
M = zeros(n,n); % Mach Numbers
x = zeros(n,n); % x-coordinates
y = zeros(n,n); % y-coordinates
%% Generate the convergent portion of a nozzle
% The inlet height/area and exit height/area(divergent) are same
% Therefore we have same A/A* = 1.6875
% Corresponding to Mach = 0.3722
%% Find NuMax (maximum expansion angle)
[~, NuMax, ~] = PMF(G,Me,0,0);
ThetaMax = NuMax/2;
%%
%ThetaMax0 = (1.0/1.687)^(2/9) * (NuMax/2);
%% Define some flow parameters of originating characteristic lines
dT = ThetaMax/n;
%no_ref = (ThetaMax – ThetaMax_ref)/dT;
ThetaArc(:,1) = (0:dT:ThetaMax);
NuArc = ThetaArc;
KmArc = ThetaArc + NuArc;
[~, ~, MuArc(:,1)] = PMF(G,0,NuArc(:,1),0);
%% Coordinates of wall along curve from throat
y0 = 1; % Define throat half-height
ThroatCurveRadius = 1.5*y0; % Radius of curvature just downstream of the throat
% for larger factors, ywall deviates from A/A* preferred value is 1.1
%L_e = 1.1 * y0 * sind(ThetaMax);
[xarc, yarc] = Arc(ThroatCurveRadius,ThetaArc); % Finds x- and y-coordinates for given theta-values
yarc(:,1) = yarc(:,1) + y0; % Defines offset due to arc being above horizontal
%% Fill in missing datapoint info along first C+ line
% First centerline datapoint done manually
Km(:,1) = KmArc(2:length(KmArc),1);
Theta(:,1) = ThetaArc(2:length(KmArc),1);
Nu(:,1) = Theta(:,1);
Kp(:,1) = Theta(:,1)-Nu(:,1);
M(1,1) = 1.0001;
Nu(1,1) = 0;
Mu(1,1) = 90;
y(1,1) = 0;
x(1,1) = xarc(2,1) + (y(1,1) – yarc(2,1))/tand((ThetaArc(2,1) – MuArc(2,1) – MuArc(2,1))/2);
% Finds the information at interior nodes along first C+ line
for i=2:n
[M(i,1), Nu(i,1), Mu(i,1)] = PMF(G,0,Nu(i,1),0);
s1 = tand((ThetaArc(i+1,1) – MuArc(i+1,1) + Theta(i,1) – Mu(i,1))/2);
s2 = tand((Theta(i-1,1) + Mu(i-1,1) + Theta(i,1) + Mu(i,1))/2);
x(i,1) = ((y(i-1,1)-x(i-1,1)*s2)-(yarc(i+1,1)-xarc(i+1,1)*s1))/(s1-s2);
y(i,1) = y(i-1,1) + (x(i,1)-x(i-1,1))*s2;
end
%% Find flow properties at remaining interior nodes
for j=2:n;
for i=1:n+1-j;
Km(i,j) = Km(i+1,j-1);
if i==1;
Theta(i,j) = 0;
Kp(i,j) = -Km(i,j);
Nu(i,j) = Km(i,j);
[M(i,j), Nu(i,j), Mu(i,j)] = PMF(G,0,Nu(i,j),0);
s1 = tand((Theta(i+1,j-1)-Mu(i+1,j-1)+Theta(i,j)-Mu(i,j))/2);
x(i,j) = x(i+1,j-1) – y(i+1,j-1)/s1;
y(i,j) = 0;
else
Kp(i,j) = Kp(i-1,j);
Theta(i,j) = (Km(i,j)+Kp(i,j))/2;
Nu(i,j) = (Km(i,j)-Kp(i,j))/2;
[M(i,j), Nu(i,j), Mu(i,j)] = PMF(G,0,Nu(i,j),0);
s1 = tand((Theta(i+1,j-1)-Mu(i+1,j-1)+Theta(i,j)-Mu(i,j))/2);
s2 = tand((Theta(i-1,j)+Mu(i-1,j)+Theta(i,j)+Mu(i,j))/2);
x(i,j) = ((y(i-1,j)-x(i-1,j)*s2)-(y(i+1,j-1)-x(i+1,j-1)*s1))/(s1-s2);
y(i,j) = y(i-1,j) + (x(i,j)-x(i-1,j))*s2;
end
end
end
%% Find wall node information
xwall = zeros(2*n,1);
ywall = xwall;
ThetaWall = ywall;
xwall(1:n,1) = xarc(2:length(xarc),1);
ywall(1:n,1) = yarc(2:length(xarc),1);
ThetaWall(1:n,1) = ThetaArc(2:length(xarc),1);
for i=1:n-1
ThetaWall(n+i,1) = ThetaWall(n-i,1); % criteria for stopping the reflection from the wall
end
%% Location of wall points
for i=1:n
s1 = tand((ThetaWall(n+i-1,1) + ThetaWall(n+i,1))/2);
s2 = tand(Theta(n+1-i,i)+Mu(n+1-i,i));
xwall(n+i,1) = ((y(n+1-i,i)-x(n+1-i,i)*s2)-(ywall(n+i-1,1)-xwall(n+i-1,1)*s1))/(s1-s2);
ywall(n+i,1) = ywall(n+i-1,1) + (xwall(n+i,1)-xwall(n+i-1,1))*s1;
end
%% Provide wall geometry to user
assignin(‘caller’,’xwall’,xwall)
assignin(‘caller’,’ywall’,ywall)
assignin(‘caller’,’Coords’,[xwall ywall])
%% Generate the convergent portion of nozzle
H_in = ywall(end);
L_e = (xwall(end)*(1.0/3.0));
[xconv,yconv] = Convergent_new_3rd(y0,H_in,L_e,n);
%%
% Draw contour and characteristic web
if display == 1
plot(xwall,ywall,’-‘)
axis equal
axis([0 ceil(xwall(length(xwall),1)) 0 ceil(ywall(length(ywall),1))])
hold on
plot(xarc,yarc,’k-‘)
for i=1:n-1
plot(x(1:n+1-i,i),y(1:n+1-i,i))
end
for i=1:n
plot([xarc(i,1) x(i,1)],[yarc(i,1) y(i,1)])
plot([x(n+1-i,i) xwall(i+n,1)],[y(n+1-i,i) ywall(i+n,1)])
end
for c=1:n
for r=2:n+1-c
plot([x(c,r) x(c+1,r-1)],[y(c,r) y(c+1,r-1)])
end
end
%hold on
%contourf(x, y, M, 20, ‘LineColor’, ‘none’); % Draw Mach number contours
%colorbar;
xlabel(‘Length [x/y0]’)
ylabel(‘Height [y/y0]’)
end
%% Non-scaled/non-dimensionalized plot
figure (1)
plot(xwall,ywall,’.b’)
title("Non dimensionalized plot")
axis equal
hold on
plot(xarc,yarc,’-‘)
hold on
plot(xconv,yconv,’-‘)
xlabel(‘xwall’)
ylabel(‘ywall’)
axis equal
%%
%{
plot(xwall,ThetaWall)
xlabel(‘xwall’)
ylabel(‘ThetaWall’)
%%
x1 = linspace(min(xwall),max(xwall),1000);
%y1 = spline(xw,yw,x1);
y1 = interp1(xwall,ywall,x1,’spline’);
figure;
title(‘Subplot 2: Cubic spline interpolation’)
plot(x1,y1,’r’)
%}
%%
%{
for i = 1:length(M)
M_centerline(i) = M(1,i);
end
for i =1:length(x)
x_axial(i) = x(1,i);
end
plot(x_axial’, Mcenterline’,’r’,’LineWidth’,2)
%}
%% Find the scaling factor
Mexit = Me;
[~,~,~,~,area] = flowisentropic(G,Mexit);
Hexit = 11.2798; %mm
Full_Throat_height = Hexit/area;
half_yt = Full_Throat_height/2.0;
%% Scaling of factors
xarc = half_yt.*xarc;
yarc = half_yt.*yarc;
xwall = half_yt.*xwall;
ywall = half_yt.*ywall;
xconv = half_yt.*xconv;
yconv = half_yt.*yconv;
%% Scaled up coordinates in mm
%{
title("Dimensionalized Plot")
plot(xwall,ywall,’-‘)
hold on
plot(xarc,yarc,’-‘)
hold on
plot(xconv,yconv,’-‘)
xlabel(‘xwall’)
ylabel(‘ywall’)
axis equal
%}
%% Combine Coordinates
% Combine xconv and xwall
coords_new_x = [xconv; xwall];
coords_new_y = [yconv; ywall];
%%
figure (2)
hold on;
plot(xconv, yconv, ‘.b’, ‘LineWidth’, 1.5) % Convergent section
plot(xwall, ywall, ‘.r’, ‘LineWidth’, 1.5) % Wall section
plot(xarc,yarc,’.g’,’LineWidth’,1.5) % arc
plot(xconv, -1.*yconv, ‘.b’, ‘LineWidth’, 1.5) % Convergent section
plot(xwall, -1.*ywall, ‘.r’, ‘LineWidth’, 1.5) % Wall section
plot(xarc,-1.*yarc,’.g’,’LineWidth’,1.5) % arc
xlabel(‘x [mm]’);
ylabel(‘y [mm]’);
title(‘Scaled up CD nozzle’);
legend(‘Convergent Section’, ‘Straightening Section’, ‘Initial Expansion (Arc)’);
grid on;
axis equal
%% Export coordinates
x1 = linspace(min(coords_new_x ),max(coords_new_x),1000);
%y1 = spline(xw,yw,x1);
y1 = interp1(coords_new_x,coords_new_y,x1,’spline’);
x2 = x1′;
y2 = y1′;
%figure;
%plot(x1,y1,’r’)
%writematrix(x2,’Spline.xlsx’,’Sheet’,1,’Range’,’A1′);
%writematrix(y2,’Spline.xlsx’,’Sheet’,1,’Range’,’B1′);
%%
%{
plot(x2,y2)
%%
plot(xwall,ywall,’-‘)
axis equal
axis([0 ceil(xwall(length(xwall),1)) 0 ceil(ywall(length(ywall),1))])
hold on
plot(xarc,yarc,’k-‘)
%}
%% Coordinates of wall
%{
writematrix(coords_new_x,’coordinates.xlsx’,’Sheet’,1,’Range’,’A1′);
writematrix(coords_new_y,’coordinates.xlsx’,’Sheet’,1,’Range’,’B1′);
%}
%%
%{
plot(x2,y2,’-k’)
hold on
plot(x2,-1.*(y2),’-r’)
grid on
title("CD Nozzle using a Circular Arc")
axis equal
%}
%% Analyze the discontinuity
% Find second-order derivative of wall contour
dy2_dx2 = zeros(size(xwall));
% Loop over all points except the last two
for i = 1:length(xwall)-2
% Calculate the second-order derivative using the forward difference formula
dy2_dx2(i) = (ywall(i+2) – 2*ywall(i+1) + ywall(i)) / (xwall(i+1) – xwall(i))^2;
end
dy2_dx2(end-1:end) = NaN; % last two points
%% Bezier Curve
threshold = 0.05; % Define a threshold for discontinuity detection (can be adjusted)
discontinuities = find(abs(diff(dy2_dx2)) > threshold);
%%
if ~isempty(discontinuities)
for idx = 1:length(discontinuities)
point_idx = discontinuities(idx); % Index of discontinuity
% Skip a few points around the discontinuity
region_start = max(1, point_idx – 2); % Upstream region
region_end = min(length(xwall), point_idx + 2); % Downstream region
% Use Bézier curve fitting only in this region to smooth the discontinuity
P0 = [xwall(region_start), ywall(region_start)]; % Start point
P1 = [xwall(point_idx), ywall(point_idx)]; % Control point (inflection/discontinuity)
P2 = [xwall(region_end), ywall(region_end)]; % End point
% Parameter t varies between 0 and 1 to interpolate the Bézier curve
t = linspace(0, 1, region_end – region_start + 1)’;
xwall(region_start:region_end) = (1-t).^2 * P0(1) + 2*(1-t).*t * P1(1) + t.^2 * P2(1);
ywall(region_start:region_end) = (1-t).^2 * P0(2) + 2*(1-t).*t * P1(2) + t.^2 * P2(2);
end
end
%%
plot(xwall,ywall,’.b’)
axis equal
%% Checking for continuous second order derivative of wall contour
cont_dy2_dx2 = zeros(size(xwall));
% Loop over all points except the last two (since forward difference needs i+2)
for i = 1:length(xwall)-2
% Calculate the second-order derivative using the forward difference formula
cont_dy2_dx2(i) = (ywall(i+2) – 2*ywall(i+1) + ywall(i)) / (xwall(i+1) – xwall(i))^2;
end
cont_dy2_dx2(end-1:end) = NaN;
plot(xwall./xwall(end), dy2_dx2) Greetings everyone, I am trying to fit a Bezier Curve as shown in the paper provide(fig1), but I am unable to get the desired plot(fig 2 and fig3). I have attached the codes as well as the paper and plot. Any help on this is highly appreciated!.
PS: The inflection point is the last point on xarc, i.e, xarc(end) and Nozzle_WithCircARc.m is the main file. It would be better to run the file cell by cell.
%function Nozzle_WithCircARc(G,Me,n,display)
%% Initialize datapoint matrices
clearvars;close all;clc;
G=1.4;
Me = 2.0;
n = 53; % speed index from pucketts paper
display = 0;
Km = zeros(n,n); % K- vlaues (Constant along right running characteristic lines)
Kp = zeros(n,n); % K+ vlaues (Constant along left running characteristic lines)
Theta = zeros(n,n); % Flow angles relative to the horizontal
Mu = zeros(n,n); % Mach angles
M = zeros(n,n); % Mach Numbers
x = zeros(n,n); % x-coordinates
y = zeros(n,n); % y-coordinates
%% Generate the convergent portion of a nozzle
% The inlet height/area and exit height/area(divergent) are same
% Therefore we have same A/A* = 1.6875
% Corresponding to Mach = 0.3722
%% Find NuMax (maximum expansion angle)
[~, NuMax, ~] = PMF(G,Me,0,0);
ThetaMax = NuMax/2;
%%
%ThetaMax0 = (1.0/1.687)^(2/9) * (NuMax/2);
%% Define some flow parameters of originating characteristic lines
dT = ThetaMax/n;
%no_ref = (ThetaMax – ThetaMax_ref)/dT;
ThetaArc(:,1) = (0:dT:ThetaMax);
NuArc = ThetaArc;
KmArc = ThetaArc + NuArc;
[~, ~, MuArc(:,1)] = PMF(G,0,NuArc(:,1),0);
%% Coordinates of wall along curve from throat
y0 = 1; % Define throat half-height
ThroatCurveRadius = 1.5*y0; % Radius of curvature just downstream of the throat
% for larger factors, ywall deviates from A/A* preferred value is 1.1
%L_e = 1.1 * y0 * sind(ThetaMax);
[xarc, yarc] = Arc(ThroatCurveRadius,ThetaArc); % Finds x- and y-coordinates for given theta-values
yarc(:,1) = yarc(:,1) + y0; % Defines offset due to arc being above horizontal
%% Fill in missing datapoint info along first C+ line
% First centerline datapoint done manually
Km(:,1) = KmArc(2:length(KmArc),1);
Theta(:,1) = ThetaArc(2:length(KmArc),1);
Nu(:,1) = Theta(:,1);
Kp(:,1) = Theta(:,1)-Nu(:,1);
M(1,1) = 1.0001;
Nu(1,1) = 0;
Mu(1,1) = 90;
y(1,1) = 0;
x(1,1) = xarc(2,1) + (y(1,1) – yarc(2,1))/tand((ThetaArc(2,1) – MuArc(2,1) – MuArc(2,1))/2);
% Finds the information at interior nodes along first C+ line
for i=2:n
[M(i,1), Nu(i,1), Mu(i,1)] = PMF(G,0,Nu(i,1),0);
s1 = tand((ThetaArc(i+1,1) – MuArc(i+1,1) + Theta(i,1) – Mu(i,1))/2);
s2 = tand((Theta(i-1,1) + Mu(i-1,1) + Theta(i,1) + Mu(i,1))/2);
x(i,1) = ((y(i-1,1)-x(i-1,1)*s2)-(yarc(i+1,1)-xarc(i+1,1)*s1))/(s1-s2);
y(i,1) = y(i-1,1) + (x(i,1)-x(i-1,1))*s2;
end
%% Find flow properties at remaining interior nodes
for j=2:n;
for i=1:n+1-j;
Km(i,j) = Km(i+1,j-1);
if i==1;
Theta(i,j) = 0;
Kp(i,j) = -Km(i,j);
Nu(i,j) = Km(i,j);
[M(i,j), Nu(i,j), Mu(i,j)] = PMF(G,0,Nu(i,j),0);
s1 = tand((Theta(i+1,j-1)-Mu(i+1,j-1)+Theta(i,j)-Mu(i,j))/2);
x(i,j) = x(i+1,j-1) – y(i+1,j-1)/s1;
y(i,j) = 0;
else
Kp(i,j) = Kp(i-1,j);
Theta(i,j) = (Km(i,j)+Kp(i,j))/2;
Nu(i,j) = (Km(i,j)-Kp(i,j))/2;
[M(i,j), Nu(i,j), Mu(i,j)] = PMF(G,0,Nu(i,j),0);
s1 = tand((Theta(i+1,j-1)-Mu(i+1,j-1)+Theta(i,j)-Mu(i,j))/2);
s2 = tand((Theta(i-1,j)+Mu(i-1,j)+Theta(i,j)+Mu(i,j))/2);
x(i,j) = ((y(i-1,j)-x(i-1,j)*s2)-(y(i+1,j-1)-x(i+1,j-1)*s1))/(s1-s2);
y(i,j) = y(i-1,j) + (x(i,j)-x(i-1,j))*s2;
end
end
end
%% Find wall node information
xwall = zeros(2*n,1);
ywall = xwall;
ThetaWall = ywall;
xwall(1:n,1) = xarc(2:length(xarc),1);
ywall(1:n,1) = yarc(2:length(xarc),1);
ThetaWall(1:n,1) = ThetaArc(2:length(xarc),1);
for i=1:n-1
ThetaWall(n+i,1) = ThetaWall(n-i,1); % criteria for stopping the reflection from the wall
end
%% Location of wall points
for i=1:n
s1 = tand((ThetaWall(n+i-1,1) + ThetaWall(n+i,1))/2);
s2 = tand(Theta(n+1-i,i)+Mu(n+1-i,i));
xwall(n+i,1) = ((y(n+1-i,i)-x(n+1-i,i)*s2)-(ywall(n+i-1,1)-xwall(n+i-1,1)*s1))/(s1-s2);
ywall(n+i,1) = ywall(n+i-1,1) + (xwall(n+i,1)-xwall(n+i-1,1))*s1;
end
%% Provide wall geometry to user
assignin(‘caller’,’xwall’,xwall)
assignin(‘caller’,’ywall’,ywall)
assignin(‘caller’,’Coords’,[xwall ywall])
%% Generate the convergent portion of nozzle
H_in = ywall(end);
L_e = (xwall(end)*(1.0/3.0));
[xconv,yconv] = Convergent_new_3rd(y0,H_in,L_e,n);
%%
% Draw contour and characteristic web
if display == 1
plot(xwall,ywall,’-‘)
axis equal
axis([0 ceil(xwall(length(xwall),1)) 0 ceil(ywall(length(ywall),1))])
hold on
plot(xarc,yarc,’k-‘)
for i=1:n-1
plot(x(1:n+1-i,i),y(1:n+1-i,i))
end
for i=1:n
plot([xarc(i,1) x(i,1)],[yarc(i,1) y(i,1)])
plot([x(n+1-i,i) xwall(i+n,1)],[y(n+1-i,i) ywall(i+n,1)])
end
for c=1:n
for r=2:n+1-c
plot([x(c,r) x(c+1,r-1)],[y(c,r) y(c+1,r-1)])
end
end
%hold on
%contourf(x, y, M, 20, ‘LineColor’, ‘none’); % Draw Mach number contours
%colorbar;
xlabel(‘Length [x/y0]’)
ylabel(‘Height [y/y0]’)
end
%% Non-scaled/non-dimensionalized plot
figure (1)
plot(xwall,ywall,’.b’)
title("Non dimensionalized plot")
axis equal
hold on
plot(xarc,yarc,’-‘)
hold on
plot(xconv,yconv,’-‘)
xlabel(‘xwall’)
ylabel(‘ywall’)
axis equal
%%
%{
plot(xwall,ThetaWall)
xlabel(‘xwall’)
ylabel(‘ThetaWall’)
%%
x1 = linspace(min(xwall),max(xwall),1000);
%y1 = spline(xw,yw,x1);
y1 = interp1(xwall,ywall,x1,’spline’);
figure;
title(‘Subplot 2: Cubic spline interpolation’)
plot(x1,y1,’r’)
%}
%%
%{
for i = 1:length(M)
M_centerline(i) = M(1,i);
end
for i =1:length(x)
x_axial(i) = x(1,i);
end
plot(x_axial’, Mcenterline’,’r’,’LineWidth’,2)
%}
%% Find the scaling factor
Mexit = Me;
[~,~,~,~,area] = flowisentropic(G,Mexit);
Hexit = 11.2798; %mm
Full_Throat_height = Hexit/area;
half_yt = Full_Throat_height/2.0;
%% Scaling of factors
xarc = half_yt.*xarc;
yarc = half_yt.*yarc;
xwall = half_yt.*xwall;
ywall = half_yt.*ywall;
xconv = half_yt.*xconv;
yconv = half_yt.*yconv;
%% Scaled up coordinates in mm
%{
title("Dimensionalized Plot")
plot(xwall,ywall,’-‘)
hold on
plot(xarc,yarc,’-‘)
hold on
plot(xconv,yconv,’-‘)
xlabel(‘xwall’)
ylabel(‘ywall’)
axis equal
%}
%% Combine Coordinates
% Combine xconv and xwall
coords_new_x = [xconv; xwall];
coords_new_y = [yconv; ywall];
%%
figure (2)
hold on;
plot(xconv, yconv, ‘.b’, ‘LineWidth’, 1.5) % Convergent section
plot(xwall, ywall, ‘.r’, ‘LineWidth’, 1.5) % Wall section
plot(xarc,yarc,’.g’,’LineWidth’,1.5) % arc
plot(xconv, -1.*yconv, ‘.b’, ‘LineWidth’, 1.5) % Convergent section
plot(xwall, -1.*ywall, ‘.r’, ‘LineWidth’, 1.5) % Wall section
plot(xarc,-1.*yarc,’.g’,’LineWidth’,1.5) % arc
xlabel(‘x [mm]’);
ylabel(‘y [mm]’);
title(‘Scaled up CD nozzle’);
legend(‘Convergent Section’, ‘Straightening Section’, ‘Initial Expansion (Arc)’);
grid on;
axis equal
%% Export coordinates
x1 = linspace(min(coords_new_x ),max(coords_new_x),1000);
%y1 = spline(xw,yw,x1);
y1 = interp1(coords_new_x,coords_new_y,x1,’spline’);
x2 = x1′;
y2 = y1′;
%figure;
%plot(x1,y1,’r’)
%writematrix(x2,’Spline.xlsx’,’Sheet’,1,’Range’,’A1′);
%writematrix(y2,’Spline.xlsx’,’Sheet’,1,’Range’,’B1′);
%%
%{
plot(x2,y2)
%%
plot(xwall,ywall,’-‘)
axis equal
axis([0 ceil(xwall(length(xwall),1)) 0 ceil(ywall(length(ywall),1))])
hold on
plot(xarc,yarc,’k-‘)
%}
%% Coordinates of wall
%{
writematrix(coords_new_x,’coordinates.xlsx’,’Sheet’,1,’Range’,’A1′);
writematrix(coords_new_y,’coordinates.xlsx’,’Sheet’,1,’Range’,’B1′);
%}
%%
%{
plot(x2,y2,’-k’)
hold on
plot(x2,-1.*(y2),’-r’)
grid on
title("CD Nozzle using a Circular Arc")
axis equal
%}
%% Analyze the discontinuity
% Find second-order derivative of wall contour
dy2_dx2 = zeros(size(xwall));
% Loop over all points except the last two
for i = 1:length(xwall)-2
% Calculate the second-order derivative using the forward difference formula
dy2_dx2(i) = (ywall(i+2) – 2*ywall(i+1) + ywall(i)) / (xwall(i+1) – xwall(i))^2;
end
dy2_dx2(end-1:end) = NaN; % last two points
%% Bezier Curve
threshold = 0.05; % Define a threshold for discontinuity detection (can be adjusted)
discontinuities = find(abs(diff(dy2_dx2)) > threshold);
%%
if ~isempty(discontinuities)
for idx = 1:length(discontinuities)
point_idx = discontinuities(idx); % Index of discontinuity
% Skip a few points around the discontinuity
region_start = max(1, point_idx – 2); % Upstream region
region_end = min(length(xwall), point_idx + 2); % Downstream region
% Use Bézier curve fitting only in this region to smooth the discontinuity
P0 = [xwall(region_start), ywall(region_start)]; % Start point
P1 = [xwall(point_idx), ywall(point_idx)]; % Control point (inflection/discontinuity)
P2 = [xwall(region_end), ywall(region_end)]; % End point
% Parameter t varies between 0 and 1 to interpolate the Bézier curve
t = linspace(0, 1, region_end – region_start + 1)’;
xwall(region_start:region_end) = (1-t).^2 * P0(1) + 2*(1-t).*t * P1(1) + t.^2 * P2(1);
ywall(region_start:region_end) = (1-t).^2 * P0(2) + 2*(1-t).*t * P1(2) + t.^2 * P2(2);
end
end
%%
plot(xwall,ywall,’.b’)
axis equal
%% Checking for continuous second order derivative of wall contour
cont_dy2_dx2 = zeros(size(xwall));
% Loop over all points except the last two (since forward difference needs i+2)
for i = 1:length(xwall)-2
% Calculate the second-order derivative using the forward difference formula
cont_dy2_dx2(i) = (ywall(i+2) – 2*ywall(i+1) + ywall(i)) / (xwall(i+1) – xwall(i))^2;
end
cont_dy2_dx2(end-1:end) = NaN;
plot(xwall./xwall(end), dy2_dx2) #curve fitting, bezier, forward difference MATLAB Answers — New Questions
QUARTERLY AVERAGE AND VARIANCE from MONTHLY DATA
I have a dataset of windspeed for each district of INDIA by month for 50 years (only the first seven are displayed below). I want to find the QUARTERLY average and VARIANCE for each district. Any help would be appreciated. Data example below
Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input str27 state str24 districts float(latitude longitude) byte month float(ws_2023 ws_2022 ws_2021 ws_2020 ws_2019 ws_2018 ws_2017)
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 1 4.589247 3.613052 4.267717 4.635023 4.930599 3.780835 4.673967
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 2 4.079226 4.215449 3.877388 4.538066 3.682131 3.676485 3.948466
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 3 3.171698 2.644508 2.92275 3.351344 3.177872 2.893883 3.182198
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 4 2.689871 2.156992 2.136186 2.872274 2.989198 2.722031 2.906296
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 5 4.14325 5.455741 3.406546 3.855165 3.735876 2.974356 3.366552
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 6 5.78509 4.582315 5.06107 4.991875 5.848218 6.734819 6.140237
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 7 6.180731 4.725333 5.93688 4.066154 5.917521 6.973715 5.876394
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 8 5.776236 5.244017 4.860325 5.294113 7.112219 7.073696 5.248257
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 9 5.926691 4.340836 4.858127 4.631201 4.920815 4.280732 4.387124
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 10 2.832476 4.086142 3.879084 3.524881 2.504806 3.259824 3.722174
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 11 3.89687 3.366515 4.069301 4.236919 3.831769 4.167921 4.207607
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 12 4.377546 4.54319 4.715546 4.315512 4.674977 4.296709 4.937579
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 1 6.210341 4.802261 6.2101 6.206068 6.416927 4.771069 6.214251
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 2 5.469119 5.677119 5.161079 6.119121 5.056155 5.20627 5.359843
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 3 4.022772 3.287575 3.717183 3.603297 3.418595 3.492516 3.59089
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 4 3.014578 2.633554 2.704057 3.562704 3.44037 3.314805 3.605515
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 5 5.758973 7.633964 4.783988 5.456239 5.274939 3.910879 4.607275
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 6 8.273372 6.252726 7.027379 7.017265 8.193433 9.077105 8.145121
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 7 8.684149 7.11254 8.41686 5.523673 7.773966 9.72518 8.343679
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 8 8.257681 7.702024 7.115208 7.253097 9.670324 9.874477 7.653042
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 9 8.256769 6.616227 6.917697 6.731298 6.786049 5.860077 6.402016
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 10 3.68233 4.764365 5.604181 5.805154 3.288253 3.944639 5.052252
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 11 5.013813 4.12091 4.951137 5.162457 5.361066 5.314161 4.652676
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 12 5.805525 6.347145 6.215302 5.600912 6.451589 5.682451 6.354571
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 1 2.071669 1.906998 1.939836 2.075697 2.161556 1.867749 2.186907
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 2 2.252566 2.123164 2.052436 2.442608 2.446047 2.056368 2.235332
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 3 2.232489 2.296364 2.168355 2.435328 2.616105 2.0682 2.37214
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 4 2.163504 2.317636 2.062944 2.230672 2.365663 2.306504 2.151902
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 5 2.233094 2.828299 2.821097 2.442079 2.263708 2.127188 2.934911
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 6 3.514094 2.797159 3.412144 3.196953 3.428785 3.854449 3.74473
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 7 4.419012 3.583243 3.530141 2.285392 3.653605 4.687582 4.112722
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 8 2.849966 3.091185 2.984837 3.136886 3.922278 5.022915 2.880093
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 9 2.927668 2.581071 2.732151 2.731299 2.755776 2.25119 2.190346
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 10 1.935015 2.111777 1.777521 2.475076 1.535323 1.955869 1.695318
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 11 2.019673 2.092834 2.257045 2.613384 2.126691 2.197218 2.132412
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 12 2.483747 2.478249 1.963105 2.345541 2.264333 2.242998 2.073321
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 1 1.987441 1.91066 1.86635 1.984144 1.924251 1.669018 1.983049
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 2 1.724246 1.956904 1.953315 2.075664 1.991458 1.761446 1.777079
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 3 1.760321 1.935036 1.757222 1.722926 1.879776 1.877282 1.911202
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 4 1.681082 2.006113 1.659624 1.749227 1.864686 1.898789 2.223191
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 5 1.778992 2.451346 2.086234 1.976747 2.230505 1.910879 1.914892
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 6 2.416438 2.145792 2.653355 2.153984 2.45271 2.329058 2.48887
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 7 3.393621 3.058341 2.791372 2.005118 2.855509 3.480551 3.17864
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 8 2.665884 2.605833 2.375462 3.258956 3.166419 3.685513 2.249233
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 9 2.15716 2.018571 2.208713 1.722998 2.432045 1.953339 1.662759
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 10 1.6794 1.821005 1.460138 1.546854 1.725753 1.699766 1.331305
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 11 2.362202 1.841369 2.649868 2.37022 1.928938 1.887892 1.993252
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 12 2.372175 2.15403 1.945038 1.970053 2.424489 2.20125 1.92171
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 1 2.011366 2.08107 1.888078 2.175307 2.046566 1.711987 2.04384
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 2 1.931765 2.307734 2.067085 2.44749 2.500002 1.985567 2.09666
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 3 2.373602 2.458717 2.115621 2.740993 2.991105 2.510094 2.925362
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 4 2.548758 2.958261 2.527299 2.988973 3.118593 3.251816 2.894578
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 5 2.386414 3.009452 3.237601 2.876161 3.080603 3.112051 2.889013
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 6 3.161067 3.017374 3.293492 2.636406 3.111402 2.99898 2.789651
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 7 3.664129 3.093009 3.062856 2.255607 3.121134 3.479086 3.147878
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 8 2.84606 2.704954 2.66013 3.023605 3.152747 3.65231 2.367398
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 9 2.383722 2.29152 2.370334 2.238135 2.599038 2.126679 1.888833
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 10 1.867388 1.978476 1.748224 1.915506 1.639327 2.064756 1.631842
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 11 2.148823 1.817687 2.462612 2.304302 1.947004 2.018751 2.124355
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 12 2.385847 2.008522 2.1362 2.018637 2.262868 2.301592 2.08919
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 1 2.016982 2.063248 1.918352 2.203383 1.990902 1.675122 2.033587
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 2 1.856081 2.255 2.059272 2.462871 2.399661 1.932588 1.99705
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 3 2.299871 2.319313 1.99648 2.563258 2.707413 2.299645 2.696358
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 4 2.327566 2.709238 2.341753 2.732137 2.801698 2.962754 2.68071
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 5 2.228699 3.014823 3.060355 2.668153 2.813513 2.880606 2.612157
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 6 3.126399 2.921671 3.138706 2.625664 3.053785 2.862261 2.795511
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 7 3.683172 3.185294 3.050161 2.216544 3.118937 3.509848 3.201589
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 8 2.813833 2.691771 2.644016 3.143722 3.177161 3.748501 2.381069
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 9 2.350031 2.26027 2.358615 2.152197 2.562905 2.069306 1.837807
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 10 1.858355 1.990195 1.677424 1.873514 1.681808 1.952695 1.604742
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 11 2.297016 1.859923 2.603725 2.351421 2.027082 2.004835 2.172207
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 12 2.444685 2.104958 2.152802 2.059896 2.402516 2.272051 2.0992
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 1 2.056532 1.886978 1.878557 2.033217 2.102474 1.978589 2.157366
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 2 2.212771 2.158808 2.061958 2.473369 2.435305 2.272676 2.309306
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 3 2.228094 2.156715 2.145406 2.709743 2.781388 2.305505 2.603585
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 4 2.488699 2.457773 2.239213 2.510946 2.591737 2.673691 2.364792
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 5 2.438172 2.945487 3.199027 2.526551 2.601599 2.514883 2.920263
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 6 3.734309 3.287393 3.806187 3.250664 3.603101 4.160601 3.837503
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 7 4.495672 3.738028 3.756704 2.563712 4.048136 4.704184 3.989675
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 8 3.301626 3.308958 3.112278 3.540206 4.179602 4.823696 2.978726
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 9 3.134211 2.628434 3.065647 2.743994 2.827065 2.477021 2.204995
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 10 2.264361 1.964804 1.912775 2.033182 1.671065 2.17169 1.69776
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 11 2.124653 1.995422 2.382534 2.313824 1.98924 2.006056 2.220546
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 12 2.34654 2.072243 1.885468 2.081381 2.116383 2.190996 2.209795
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 1 2.44496 2.590836 2.425676 2.605971 2.501644 2.515942 2.757463
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 2 2.508425 2.762568 2.567573 3.126446 3.197756 2.60129 2.800029
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 3 3.205389 3.237282 2.953511 3.691676 4.10756 3.36654 4.029366
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 4 3.662039 3.821054 3.530229 3.994833 4.279237 4.280625 4.094285
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 5 3.212586 3.671073 4.05303 3.806825 4.215857 3.95336 3.870458
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 6 3.785578 3.46171 3.949253 3.267265 3.760816 3.631304 3.623147
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 7 4.028875 3.644278 3.422719 2.675529 3.510783 4.426352 3.740652
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 8 3.309439 3.221068 3.280735 2.928878 3.648352 4.515591 3.001187
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 9 3.065851 2.845231 2.899631 2.802588 3.053627 2.959442 2.436929
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 10 2.54024 2.594199 2.424494 2.607889 2.401534 2.679014 2.344
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 11 2.683003 2.720275 3.157192 3.142681 2.674055 2.672804 2.926601
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 12 3.434187 2.877907 2.651093 3.038168 2.910573 2.87581 2.851641
"ANDHRA PRADESH" "Srikakulam" 18.2949 83.8938 1 3.073378 3.212418 2.792619 3.054945 2.819027 2.648022 2.986223
"ANDHRA PRADESH" "Srikakulam" 18.2949 83.8938 2 3.036501 3.030879 3.170356 3.00584 3.223879 2.857637 2.92332
"ANDHRA PRADESH" "Srikakulam" 18.2949 83.8938 3 3.2237 3.786842 3.660542 3.183375 4.176651 4.108239 4.844308
"ANDHRA PRADESH" "Srikakulam" 18.2949 83.8938 4 3.600516 5.530527 4.27437 4.589071 4.829042 5.10582 5.711472
endI have a dataset of windspeed for each district of INDIA by month for 50 years (only the first seven are displayed below). I want to find the QUARTERLY average and VARIANCE for each district. Any help would be appreciated. Data example below
Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input str27 state str24 districts float(latitude longitude) byte month float(ws_2023 ws_2022 ws_2021 ws_2020 ws_2019 ws_2018 ws_2017)
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 1 4.589247 3.613052 4.267717 4.635023 4.930599 3.780835 4.673967
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 2 4.079226 4.215449 3.877388 4.538066 3.682131 3.676485 3.948466
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 3 3.171698 2.644508 2.92275 3.351344 3.177872 2.893883 3.182198
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 4 2.689871 2.156992 2.136186 2.872274 2.989198 2.722031 2.906296
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 5 4.14325 5.455741 3.406546 3.855165 3.735876 2.974356 3.366552
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 6 5.78509 4.582315 5.06107 4.991875 5.848218 6.734819 6.140237
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 7 6.180731 4.725333 5.93688 4.066154 5.917521 6.973715 5.876394
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 8 5.776236 5.244017 4.860325 5.294113 7.112219 7.073696 5.248257
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 9 5.926691 4.340836 4.858127 4.631201 4.920815 4.280732 4.387124
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 10 2.832476 4.086142 3.879084 3.524881 2.504806 3.259824 3.722174
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 11 3.89687 3.366515 4.069301 4.236919 3.831769 4.167921 4.207607
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 12 4.377546 4.54319 4.715546 4.315512 4.674977 4.296709 4.937579
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 1 6.210341 4.802261 6.2101 6.206068 6.416927 4.771069 6.214251
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 2 5.469119 5.677119 5.161079 6.119121 5.056155 5.20627 5.359843
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 3 4.022772 3.287575 3.717183 3.603297 3.418595 3.492516 3.59089
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 4 3.014578 2.633554 2.704057 3.562704 3.44037 3.314805 3.605515
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 5 5.758973 7.633964 4.783988 5.456239 5.274939 3.910879 4.607275
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 6 8.273372 6.252726 7.027379 7.017265 8.193433 9.077105 8.145121
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 7 8.684149 7.11254 8.41686 5.523673 7.773966 9.72518 8.343679
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 8 8.257681 7.702024 7.115208 7.253097 9.670324 9.874477 7.653042
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 9 8.256769 6.616227 6.917697 6.731298 6.786049 5.860077 6.402016
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 10 3.68233 4.764365 5.604181 5.805154 3.288253 3.944639 5.052252
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 11 5.013813 4.12091 4.951137 5.162457 5.361066 5.314161 4.652676
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 12 5.805525 6.347145 6.215302 5.600912 6.451589 5.682451 6.354571
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 1 2.071669 1.906998 1.939836 2.075697 2.161556 1.867749 2.186907
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 2 2.252566 2.123164 2.052436 2.442608 2.446047 2.056368 2.235332
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 3 2.232489 2.296364 2.168355 2.435328 2.616105 2.0682 2.37214
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 4 2.163504 2.317636 2.062944 2.230672 2.365663 2.306504 2.151902
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 5 2.233094 2.828299 2.821097 2.442079 2.263708 2.127188 2.934911
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 6 3.514094 2.797159 3.412144 3.196953 3.428785 3.854449 3.74473
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 7 4.419012 3.583243 3.530141 2.285392 3.653605 4.687582 4.112722
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 8 2.849966 3.091185 2.984837 3.136886 3.922278 5.022915 2.880093
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 9 2.927668 2.581071 2.732151 2.731299 2.755776 2.25119 2.190346
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 10 1.935015 2.111777 1.777521 2.475076 1.535323 1.955869 1.695318
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 11 2.019673 2.092834 2.257045 2.613384 2.126691 2.197218 2.132412
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 12 2.483747 2.478249 1.963105 2.345541 2.264333 2.242998 2.073321
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 1 1.987441 1.91066 1.86635 1.984144 1.924251 1.669018 1.983049
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 2 1.724246 1.956904 1.953315 2.075664 1.991458 1.761446 1.777079
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 3 1.760321 1.935036 1.757222 1.722926 1.879776 1.877282 1.911202
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 4 1.681082 2.006113 1.659624 1.749227 1.864686 1.898789 2.223191
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 5 1.778992 2.451346 2.086234 1.976747 2.230505 1.910879 1.914892
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 6 2.416438 2.145792 2.653355 2.153984 2.45271 2.329058 2.48887
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 7 3.393621 3.058341 2.791372 2.005118 2.855509 3.480551 3.17864
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 8 2.665884 2.605833 2.375462 3.258956 3.166419 3.685513 2.249233
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 9 2.15716 2.018571 2.208713 1.722998 2.432045 1.953339 1.662759
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 10 1.6794 1.821005 1.460138 1.546854 1.725753 1.699766 1.331305
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 11 2.362202 1.841369 2.649868 2.37022 1.928938 1.887892 1.993252
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 12 2.372175 2.15403 1.945038 1.970053 2.424489 2.20125 1.92171
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 1 2.011366 2.08107 1.888078 2.175307 2.046566 1.711987 2.04384
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 2 1.931765 2.307734 2.067085 2.44749 2.500002 1.985567 2.09666
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 3 2.373602 2.458717 2.115621 2.740993 2.991105 2.510094 2.925362
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 4 2.548758 2.958261 2.527299 2.988973 3.118593 3.251816 2.894578
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 5 2.386414 3.009452 3.237601 2.876161 3.080603 3.112051 2.889013
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 6 3.161067 3.017374 3.293492 2.636406 3.111402 2.99898 2.789651
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 7 3.664129 3.093009 3.062856 2.255607 3.121134 3.479086 3.147878
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 8 2.84606 2.704954 2.66013 3.023605 3.152747 3.65231 2.367398
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 9 2.383722 2.29152 2.370334 2.238135 2.599038 2.126679 1.888833
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 10 1.867388 1.978476 1.748224 1.915506 1.639327 2.064756 1.631842
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 11 2.148823 1.817687 2.462612 2.304302 1.947004 2.018751 2.124355
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 12 2.385847 2.008522 2.1362 2.018637 2.262868 2.301592 2.08919
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 1 2.016982 2.063248 1.918352 2.203383 1.990902 1.675122 2.033587
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 2 1.856081 2.255 2.059272 2.462871 2.399661 1.932588 1.99705
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 3 2.299871 2.319313 1.99648 2.563258 2.707413 2.299645 2.696358
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 4 2.327566 2.709238 2.341753 2.732137 2.801698 2.962754 2.68071
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 5 2.228699 3.014823 3.060355 2.668153 2.813513 2.880606 2.612157
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 6 3.126399 2.921671 3.138706 2.625664 3.053785 2.862261 2.795511
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 7 3.683172 3.185294 3.050161 2.216544 3.118937 3.509848 3.201589
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 8 2.813833 2.691771 2.644016 3.143722 3.177161 3.748501 2.381069
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 9 2.350031 2.26027 2.358615 2.152197 2.562905 2.069306 1.837807
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 10 1.858355 1.990195 1.677424 1.873514 1.681808 1.952695 1.604742
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 11 2.297016 1.859923 2.603725 2.351421 2.027082 2.004835 2.172207
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 12 2.444685 2.104958 2.152802 2.059896 2.402516 2.272051 2.0992
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 1 2.056532 1.886978 1.878557 2.033217 2.102474 1.978589 2.157366
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 2 2.212771 2.158808 2.061958 2.473369 2.435305 2.272676 2.309306
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 3 2.228094 2.156715 2.145406 2.709743 2.781388 2.305505 2.603585
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 4 2.488699 2.457773 2.239213 2.510946 2.591737 2.673691 2.364792
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 5 2.438172 2.945487 3.199027 2.526551 2.601599 2.514883 2.920263
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 6 3.734309 3.287393 3.806187 3.250664 3.603101 4.160601 3.837503
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 7 4.495672 3.738028 3.756704 2.563712 4.048136 4.704184 3.989675
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 8 3.301626 3.308958 3.112278 3.540206 4.179602 4.823696 2.978726
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 9 3.134211 2.628434 3.065647 2.743994 2.827065 2.477021 2.204995
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 10 2.264361 1.964804 1.912775 2.033182 1.671065 2.17169 1.69776
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 11 2.124653 1.995422 2.382534 2.313824 1.98924 2.006056 2.220546
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 12 2.34654 2.072243 1.885468 2.081381 2.116383 2.190996 2.209795
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 1 2.44496 2.590836 2.425676 2.605971 2.501644 2.515942 2.757463
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 2 2.508425 2.762568 2.567573 3.126446 3.197756 2.60129 2.800029
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 3 3.205389 3.237282 2.953511 3.691676 4.10756 3.36654 4.029366
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 4 3.662039 3.821054 3.530229 3.994833 4.279237 4.280625 4.094285
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 5 3.212586 3.671073 4.05303 3.806825 4.215857 3.95336 3.870458
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 6 3.785578 3.46171 3.949253 3.267265 3.760816 3.631304 3.623147
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 7 4.028875 3.644278 3.422719 2.675529 3.510783 4.426352 3.740652
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 8 3.309439 3.221068 3.280735 2.928878 3.648352 4.515591 3.001187
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 9 3.065851 2.845231 2.899631 2.802588 3.053627 2.959442 2.436929
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 10 2.54024 2.594199 2.424494 2.607889 2.401534 2.679014 2.344
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 11 2.683003 2.720275 3.157192 3.142681 2.674055 2.672804 2.926601
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 12 3.434187 2.877907 2.651093 3.038168 2.910573 2.87581 2.851641
"ANDHRA PRADESH" "Srikakulam" 18.2949 83.8938 1 3.073378 3.212418 2.792619 3.054945 2.819027 2.648022 2.986223
"ANDHRA PRADESH" "Srikakulam" 18.2949 83.8938 2 3.036501 3.030879 3.170356 3.00584 3.223879 2.857637 2.92332
"ANDHRA PRADESH" "Srikakulam" 18.2949 83.8938 3 3.2237 3.786842 3.660542 3.183375 4.176651 4.108239 4.844308
"ANDHRA PRADESH" "Srikakulam" 18.2949 83.8938 4 3.600516 5.530527 4.27437 4.589071 4.829042 5.10582 5.711472
end I have a dataset of windspeed for each district of INDIA by month for 50 years (only the first seven are displayed below). I want to find the QUARTERLY average and VARIANCE for each district. Any help would be appreciated. Data example below
Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input str27 state str24 districts float(latitude longitude) byte month float(ws_2023 ws_2022 ws_2021 ws_2020 ws_2019 ws_2018 ws_2017)
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 1 4.589247 3.613052 4.267717 4.635023 4.930599 3.780835 4.673967
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 2 4.079226 4.215449 3.877388 4.538066 3.682131 3.676485 3.948466
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 3 3.171698 2.644508 2.92275 3.351344 3.177872 2.893883 3.182198
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 4 2.689871 2.156992 2.136186 2.872274 2.989198 2.722031 2.906296
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 5 4.14325 5.455741 3.406546 3.855165 3.735876 2.974356 3.366552
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 6 5.78509 4.582315 5.06107 4.991875 5.848218 6.734819 6.140237
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 7 6.180731 4.725333 5.93688 4.066154 5.917521 6.973715 5.876394
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 8 5.776236 5.244017 4.860325 5.294113 7.112219 7.073696 5.248257
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 9 5.926691 4.340836 4.858127 4.631201 4.920815 4.280732 4.387124
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 10 2.832476 4.086142 3.879084 3.524881 2.504806 3.259824 3.722174
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 11 3.89687 3.366515 4.069301 4.236919 3.831769 4.167921 4.207607
"ANDAMAN AND NICOBAR ISLANDS" "North and Middle Andaman" 12.5601 92.8976 12 4.377546 4.54319 4.715546 4.315512 4.674977 4.296709 4.937579
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 1 6.210341 4.802261 6.2101 6.206068 6.416927 4.771069 6.214251
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 2 5.469119 5.677119 5.161079 6.119121 5.056155 5.20627 5.359843
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 3 4.022772 3.287575 3.717183 3.603297 3.418595 3.492516 3.59089
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 4 3.014578 2.633554 2.704057 3.562704 3.44037 3.314805 3.605515
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 5 5.758973 7.633964 4.783988 5.456239 5.274939 3.910879 4.607275
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 6 8.273372 6.252726 7.027379 7.017265 8.193433 9.077105 8.145121
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 7 8.684149 7.11254 8.41686 5.523673 7.773966 9.72518 8.343679
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 8 8.257681 7.702024 7.115208 7.253097 9.670324 9.874477 7.653042
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 9 8.256769 6.616227 6.917697 6.731298 6.786049 5.860077 6.402016
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 10 3.68233 4.764365 5.604181 5.805154 3.288253 3.944639 5.052252
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 11 5.013813 4.12091 4.951137 5.162457 5.361066 5.314161 4.652676
"ANDAMAN AND NICOBAR ISLANDS" "South Andaman" 10.7449 92.5 12 5.805525 6.347145 6.215302 5.600912 6.451589 5.682451 6.354571
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 1 2.071669 1.906998 1.939836 2.075697 2.161556 1.867749 2.186907
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 2 2.252566 2.123164 2.052436 2.442608 2.446047 2.056368 2.235332
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 3 2.232489 2.296364 2.168355 2.435328 2.616105 2.0682 2.37214
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 4 2.163504 2.317636 2.062944 2.230672 2.365663 2.306504 2.151902
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 5 2.233094 2.828299 2.821097 2.442079 2.263708 2.127188 2.934911
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 6 3.514094 2.797159 3.412144 3.196953 3.428785 3.854449 3.74473
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 7 4.419012 3.583243 3.530141 2.285392 3.653605 4.687582 4.112722
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 8 2.849966 3.091185 2.984837 3.136886 3.922278 5.022915 2.880093
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 9 2.927668 2.581071 2.732151 2.731299 2.755776 2.25119 2.190346
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 10 1.935015 2.111777 1.777521 2.475076 1.535323 1.955869 1.695318
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 11 2.019673 2.092834 2.257045 2.613384 2.126691 2.197218 2.132412
"ANDHRA PRADESH" "Chittoor" 13.2172 79.1003 12 2.483747 2.478249 1.963105 2.345541 2.264333 2.242998 2.073321
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 1 1.987441 1.91066 1.86635 1.984144 1.924251 1.669018 1.983049
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 2 1.724246 1.956904 1.953315 2.075664 1.991458 1.761446 1.777079
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 3 1.760321 1.935036 1.757222 1.722926 1.879776 1.877282 1.911202
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 4 1.681082 2.006113 1.659624 1.749227 1.864686 1.898789 2.223191
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 5 1.778992 2.451346 2.086234 1.976747 2.230505 1.910879 1.914892
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 6 2.416438 2.145792 2.653355 2.153984 2.45271 2.329058 2.48887
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 7 3.393621 3.058341 2.791372 2.005118 2.855509 3.480551 3.17864
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 8 2.665884 2.605833 2.375462 3.258956 3.166419 3.685513 2.249233
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 9 2.15716 2.018571 2.208713 1.722998 2.432045 1.953339 1.662759
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 10 1.6794 1.821005 1.460138 1.546854 1.725753 1.699766 1.331305
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 11 2.362202 1.841369 2.649868 2.37022 1.928938 1.887892 1.993252
"ANDHRA PRADESH" "East Godavari" 17.3213 82.0407 12 2.372175 2.15403 1.945038 1.970053 2.424489 2.20125 1.92171
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 1 2.011366 2.08107 1.888078 2.175307 2.046566 1.711987 2.04384
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 2 1.931765 2.307734 2.067085 2.44749 2.500002 1.985567 2.09666
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 3 2.373602 2.458717 2.115621 2.740993 2.991105 2.510094 2.925362
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 4 2.548758 2.958261 2.527299 2.988973 3.118593 3.251816 2.894578
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 5 2.386414 3.009452 3.237601 2.876161 3.080603 3.112051 2.889013
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 6 3.161067 3.017374 3.293492 2.636406 3.111402 2.99898 2.789651
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 7 3.664129 3.093009 3.062856 2.255607 3.121134 3.479086 3.147878
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 8 2.84606 2.704954 2.66013 3.023605 3.152747 3.65231 2.367398
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 9 2.383722 2.29152 2.370334 2.238135 2.599038 2.126679 1.888833
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 10 1.867388 1.978476 1.748224 1.915506 1.639327 2.064756 1.631842
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 11 2.148823 1.817687 2.462612 2.304302 1.947004 2.018751 2.124355
"ANDHRA PRADESH" "Guntur" 16.3067 80.4365 12 2.385847 2.008522 2.1362 2.018637 2.262868 2.301592 2.08919
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 1 2.016982 2.063248 1.918352 2.203383 1.990902 1.675122 2.033587
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 2 1.856081 2.255 2.059272 2.462871 2.399661 1.932588 1.99705
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 3 2.299871 2.319313 1.99648 2.563258 2.707413 2.299645 2.696358
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 4 2.327566 2.709238 2.341753 2.732137 2.801698 2.962754 2.68071
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 5 2.228699 3.014823 3.060355 2.668153 2.813513 2.880606 2.612157
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 6 3.126399 2.921671 3.138706 2.625664 3.053785 2.862261 2.795511
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 7 3.683172 3.185294 3.050161 2.216544 3.118937 3.509848 3.201589
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 8 2.813833 2.691771 2.644016 3.143722 3.177161 3.748501 2.381069
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 9 2.350031 2.26027 2.358615 2.152197 2.562905 2.069306 1.837807
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 10 1.858355 1.990195 1.677424 1.873514 1.681808 1.952695 1.604742
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 11 2.297016 1.859923 2.603725 2.351421 2.027082 2.004835 2.172207
"ANDHRA PRADESH" "Krishna" 16.61 80.7214 12 2.444685 2.104958 2.152802 2.059896 2.402516 2.272051 2.0992
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 1 2.056532 1.886978 1.878557 2.033217 2.102474 1.978589 2.157366
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 2 2.212771 2.158808 2.061958 2.473369 2.435305 2.272676 2.309306
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 3 2.228094 2.156715 2.145406 2.709743 2.781388 2.305505 2.603585
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 4 2.488699 2.457773 2.239213 2.510946 2.591737 2.673691 2.364792
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 5 2.438172 2.945487 3.199027 2.526551 2.601599 2.514883 2.920263
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 6 3.734309 3.287393 3.806187 3.250664 3.603101 4.160601 3.837503
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 7 4.495672 3.738028 3.756704 2.563712 4.048136 4.704184 3.989675
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 8 3.301626 3.308958 3.112278 3.540206 4.179602 4.823696 2.978726
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 9 3.134211 2.628434 3.065647 2.743994 2.827065 2.477021 2.204995
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 10 2.264361 1.964804 1.912775 2.033182 1.671065 2.17169 1.69776
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 11 2.124653 1.995422 2.382534 2.313824 1.98924 2.006056 2.220546
"ANDHRA PRADESH" "Prakasam" 15.3485 79.5603 12 2.34654 2.072243 1.885468 2.081381 2.116383 2.190996 2.209795
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 1 2.44496 2.590836 2.425676 2.605971 2.501644 2.515942 2.757463
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 2 2.508425 2.762568 2.567573 3.126446 3.197756 2.60129 2.800029
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 3 3.205389 3.237282 2.953511 3.691676 4.10756 3.36654 4.029366
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 4 3.662039 3.821054 3.530229 3.994833 4.279237 4.280625 4.094285
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 5 3.212586 3.671073 4.05303 3.806825 4.215857 3.95336 3.870458
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 6 3.785578 3.46171 3.949253 3.267265 3.760816 3.631304 3.623147
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 7 4.028875 3.644278 3.422719 2.675529 3.510783 4.426352 3.740652
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 8 3.309439 3.221068 3.280735 2.928878 3.648352 4.515591 3.001187
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 9 3.065851 2.845231 2.899631 2.802588 3.053627 2.959442 2.436929
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 10 2.54024 2.594199 2.424494 2.607889 2.401534 2.679014 2.344
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 11 2.683003 2.720275 3.157192 3.142681 2.674055 2.672804 2.926601
"ANDHRA PRADESH" "SPS Nellore" 14.2581 79.9193 12 3.434187 2.877907 2.651093 3.038168 2.910573 2.87581 2.851641
"ANDHRA PRADESH" "Srikakulam" 18.2949 83.8938 1 3.073378 3.212418 2.792619 3.054945 2.819027 2.648022 2.986223
"ANDHRA PRADESH" "Srikakulam" 18.2949 83.8938 2 3.036501 3.030879 3.170356 3.00584 3.223879 2.857637 2.92332
"ANDHRA PRADESH" "Srikakulam" 18.2949 83.8938 3 3.2237 3.786842 3.660542 3.183375 4.176651 4.108239 4.844308
"ANDHRA PRADESH" "Srikakulam" 18.2949 83.8938 4 3.600516 5.530527 4.27437 4.589071 4.829042 5.10582 5.711472
end data analysis MATLAB Answers — New Questions
Y double axis required trendlines
x = [1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020];
y1 = [18.1969 15.834 16.5986 3.1579 10.9866 8.2062 8.9229 9.6429 6.4604 14.805 9.1178 0.49 2.9925 8.7875 5.7404 5.365 8.32 13.025 10.9654 3.26 8.975 4.795 0.97 32.3175 11.1025 0.65 9.5425 12.115 9.8975 21.875 16.6925];
y2 = [17.360463 15.30933 12.563672 2.174533 8.407282 5.828774 4.764783 5.524783 3.644908 15.515 7.022406 0.1715 1.168625 4.729125 3.232158 2.149 6.37575 12.0585 7.024658 1.355 5.591 3.088 0.396 25.004125 8.130375 0.2355 5.040375 7.95375 5.477375 18.4155 16.567625];
figure(‘Color’,’w’)
[hAx,hLine1,hLine2] = plotyy(x,y1,x,y2);
ylabel(hAx(1),’ACE (knot^2)’) % left y-axis
ylabel(hAx(2),’PDI (knot^3)’) % right y-axis
%grid onx = [1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020];
y1 = [18.1969 15.834 16.5986 3.1579 10.9866 8.2062 8.9229 9.6429 6.4604 14.805 9.1178 0.49 2.9925 8.7875 5.7404 5.365 8.32 13.025 10.9654 3.26 8.975 4.795 0.97 32.3175 11.1025 0.65 9.5425 12.115 9.8975 21.875 16.6925];
y2 = [17.360463 15.30933 12.563672 2.174533 8.407282 5.828774 4.764783 5.524783 3.644908 15.515 7.022406 0.1715 1.168625 4.729125 3.232158 2.149 6.37575 12.0585 7.024658 1.355 5.591 3.088 0.396 25.004125 8.130375 0.2355 5.040375 7.95375 5.477375 18.4155 16.567625];
figure(‘Color’,’w’)
[hAx,hLine1,hLine2] = plotyy(x,y1,x,y2);
ylabel(hAx(1),’ACE (knot^2)’) % left y-axis
ylabel(hAx(2),’PDI (knot^3)’) % right y-axis
%grid on x = [1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020];
y1 = [18.1969 15.834 16.5986 3.1579 10.9866 8.2062 8.9229 9.6429 6.4604 14.805 9.1178 0.49 2.9925 8.7875 5.7404 5.365 8.32 13.025 10.9654 3.26 8.975 4.795 0.97 32.3175 11.1025 0.65 9.5425 12.115 9.8975 21.875 16.6925];
y2 = [17.360463 15.30933 12.563672 2.174533 8.407282 5.828774 4.764783 5.524783 3.644908 15.515 7.022406 0.1715 1.168625 4.729125 3.232158 2.149 6.37575 12.0585 7.024658 1.355 5.591 3.088 0.396 25.004125 8.130375 0.2355 5.040375 7.95375 5.477375 18.4155 16.567625];
figure(‘Color’,’w’)
[hAx,hLine1,hLine2] = plotyy(x,y1,x,y2);
ylabel(hAx(1),’ACE (knot^2)’) % left y-axis
ylabel(hAx(2),’PDI (knot^3)’) % right y-axis
%grid on trendline, y double axis MATLAB Answers — New Questions
Is it possible to convert Arduino IDE Code (C++ Code) to MATLAB Code by any means? Or does it have to be done manually?
I’m trying to translate a C++ Code which is used for Soil Moisture Sensor and Raindrop Sensor to a MATLAB Code. I was hoping to convert the C++ Code to a MATLAB Code through faster means since I have no knowledge in C++ Coding. Following is the code.
const int capteur_D = 4;
const int capteur_A = A0;
int val_analogique;
int soilMoistureValue = 0;
int soilmoisturepercent=0;
void setup() {
pinMode(capteur_D, INPUT);
pinMode(capteur_A, INPUT);
Serial.begin(9600); // open serial port, set the baud rate to 9600 bps
}
void loop() {
soilMoistureValue = analogRead(A0); //put Sensor insert into soil
Serial.println(soilMoistureValue);
delay(250);
if(digitalRead(capteur_D) == LOW)
{
Serial.println("Digital value : wet");
delay(10);
}
else
{
Serial.println("Digital value : dry");
delay(10);
}
val_analogique=analogRead(capteur_A);
Serial.print("Analog value : ");
Serial.println(val_analogique);
Serial.println("");
delay(1000);
}I’m trying to translate a C++ Code which is used for Soil Moisture Sensor and Raindrop Sensor to a MATLAB Code. I was hoping to convert the C++ Code to a MATLAB Code through faster means since I have no knowledge in C++ Coding. Following is the code.
const int capteur_D = 4;
const int capteur_A = A0;
int val_analogique;
int soilMoistureValue = 0;
int soilmoisturepercent=0;
void setup() {
pinMode(capteur_D, INPUT);
pinMode(capteur_A, INPUT);
Serial.begin(9600); // open serial port, set the baud rate to 9600 bps
}
void loop() {
soilMoistureValue = analogRead(A0); //put Sensor insert into soil
Serial.println(soilMoistureValue);
delay(250);
if(digitalRead(capteur_D) == LOW)
{
Serial.println("Digital value : wet");
delay(10);
}
else
{
Serial.println("Digital value : dry");
delay(10);
}
val_analogique=analogRead(capteur_A);
Serial.print("Analog value : ");
Serial.println(val_analogique);
Serial.println("");
delay(1000);
} I’m trying to translate a C++ Code which is used for Soil Moisture Sensor and Raindrop Sensor to a MATLAB Code. I was hoping to convert the C++ Code to a MATLAB Code through faster means since I have no knowledge in C++ Coding. Following is the code.
const int capteur_D = 4;
const int capteur_A = A0;
int val_analogique;
int soilMoistureValue = 0;
int soilmoisturepercent=0;
void setup() {
pinMode(capteur_D, INPUT);
pinMode(capteur_A, INPUT);
Serial.begin(9600); // open serial port, set the baud rate to 9600 bps
}
void loop() {
soilMoistureValue = analogRead(A0); //put Sensor insert into soil
Serial.println(soilMoistureValue);
delay(250);
if(digitalRead(capteur_D) == LOW)
{
Serial.println("Digital value : wet");
delay(10);
}
else
{
Serial.println("Digital value : dry");
delay(10);
}
val_analogique=analogRead(capteur_A);
Serial.print("Analog value : ");
Serial.println(val_analogique);
Serial.println("");
delay(1000);
} c++, c++ to matlab MATLAB Answers — New Questions
Errors while linking unreal engine to matlab
Unreal Engine: 5.1.1
Matlab Release: R2024a
I am trying to make a custom scene in unreal engine, for that I installed Aerospace Toolbox Unreal ENgine Interface, after installing, when I try to opne the editor using
`editor.open()’
I get following message:
I tried to build it through IDE but it gave me the following error:
I need help resolving this issue.Unreal Engine: 5.1.1
Matlab Release: R2024a
I am trying to make a custom scene in unreal engine, for that I installed Aerospace Toolbox Unreal ENgine Interface, after installing, when I try to opne the editor using
`editor.open()’
I get following message:
I tried to build it through IDE but it gave me the following error:
I need help resolving this issue. Unreal Engine: 5.1.1
Matlab Release: R2024a
I am trying to make a custom scene in unreal engine, for that I installed Aerospace Toolbox Unreal ENgine Interface, after installing, when I try to opne the editor using
`editor.open()’
I get following message:
I tried to build it through IDE but it gave me the following error:
I need help resolving this issue. unrealengine MATLAB Answers — New Questions
Over time reduce an input value linearly with a delay after each decrement, using a Simulink model
I’m trying to create a Simulink model that has an input value that I want to reduce down to zero in a specific time. It must decrease in linear decrements with a delay after each decrement. The initial input value can also be different, but must reduce down to zero in the same time no matter the starting value.
I have tried using a feedback loop to subtract the original value * the time step, but this just results in the output value decreasing to zero immediately.
Are there any specific blocks for this kind fo linear reduction, or is a more complex block system required?
Thanks for the helpI’m trying to create a Simulink model that has an input value that I want to reduce down to zero in a specific time. It must decrease in linear decrements with a delay after each decrement. The initial input value can also be different, but must reduce down to zero in the same time no matter the starting value.
I have tried using a feedback loop to subtract the original value * the time step, but this just results in the output value decreasing to zero immediately.
Are there any specific blocks for this kind fo linear reduction, or is a more complex block system required?
Thanks for the help I’m trying to create a Simulink model that has an input value that I want to reduce down to zero in a specific time. It must decrease in linear decrements with a delay after each decrement. The initial input value can also be different, but must reduce down to zero in the same time no matter the starting value.
I have tried using a feedback loop to subtract the original value * the time step, but this just results in the output value decreasing to zero immediately.
Are there any specific blocks for this kind fo linear reduction, or is a more complex block system required?
Thanks for the help simulink, feedback loop MATLAB Answers — New Questions
YOLOX – training on tiled images and inference on full-size images
Hello everyone. I am trying to train the YOLOX net for cell detection in brightfield. My original images are 2048×2048. I read on matworks that yolox, being anchor-free, can be trained on tiled images and the inference can be done on full-size images. So what I did was tiliing my images in 4 blocks, 1024×1024 each, then size down everything to 512×512 pixels and do the training. Doing the inference on full-size images gives me 0 precision, as well as scaling down the test set to 1024×1024 pixels, which makes the size of the cells I want to detect the same size as they would be in the preprocessed training set. Is there something I am not grasping due to my scarce experience? thank you to whoever will suggest something. ThanksHello everyone. I am trying to train the YOLOX net for cell detection in brightfield. My original images are 2048×2048. I read on matworks that yolox, being anchor-free, can be trained on tiled images and the inference can be done on full-size images. So what I did was tiliing my images in 4 blocks, 1024×1024 each, then size down everything to 512×512 pixels and do the training. Doing the inference on full-size images gives me 0 precision, as well as scaling down the test set to 1024×1024 pixels, which makes the size of the cells I want to detect the same size as they would be in the preprocessed training set. Is there something I am not grasping due to my scarce experience? thank you to whoever will suggest something. Thanks Hello everyone. I am trying to train the YOLOX net for cell detection in brightfield. My original images are 2048×2048. I read on matworks that yolox, being anchor-free, can be trained on tiled images and the inference can be done on full-size images. So what I did was tiliing my images in 4 blocks, 1024×1024 each, then size down everything to 512×512 pixels and do the training. Doing the inference on full-size images gives me 0 precision, as well as scaling down the test set to 1024×1024 pixels, which makes the size of the cells I want to detect the same size as they would be in the preprocessed training set. Is there something I am not grasping due to my scarce experience? thank you to whoever will suggest something. Thanks yolo, deep learning, detection, machine learning, image processing, computer vision MATLAB Answers — New Questions
error when using lsqnonlin to function containing fzero function
I want to use lsqnonlin analysis to fit a model to two sets of data and obtain values of 4 variables. The function i created contains fzero function which only allows scalar values and i finally got the error ‘operands to the || and && operators ust be convertible to logical scalar values. ‘ So is there any other method that can replace lsqnonlin to solve my problem? Or any corrections, changes to be made in my code to solve this with lsqnonlin? Thanks! Here’s my function file and code.
function Result = myfunc1(a,p,G,m,fraction)
totalconcentration = 0.0000291;
n = 2;
K = exp(-((G + m * fraction)./(8.314*298)));
g_lb = 0;
g_ub = 0.9999;
g =[g_lb g_ub];
monomerconcentration = fzero(@denaturationfun,g);
function y = denaturationfun(x)
y = a.^(-1).*(((a.*x).^(n+1)).*(n.*a.*x-n-1)/((a.*x-1).^2)+a.*x/((a.*x-1).^2))-a.^(n-1).*((x^(n+1)).*(n.*x-n-1)/((x-1).^2))-K.*totalconcentration;
end
Result = p * (1- (monomerconcentration / ( K * totalconcentration )));
end
clc;
clear;
close all;
fractiondata = [0.1505 0.1546 0.1587 0.1628 0.1668 0.1708 0.1748 0.1787 0.1825 0.1864 0.1902 0.194 0.1977 0.2014 0.205 0.2087 0.2123];
DegreeofAggdata = [1 0.9087 0.8658 0.83453 0.79569 0.67979 0.62031 0.53043 0.39722 0.25888 0.15171 0.04759 0.00109 3.20E-04 0.00144 7.77E-04 0];
fun = @(x)DegreeofAggdata – myfunc1(x(1),x(2),x(3),x(4),fractiondata);
x0 = [0.01,0.9,-50000,100000];
lb = [0.00001,0.9,-100000,20000];
ub = [1,1.1,-10000,130000];
x = lsqnonlin(fun,x0,lb,ub);I want to use lsqnonlin analysis to fit a model to two sets of data and obtain values of 4 variables. The function i created contains fzero function which only allows scalar values and i finally got the error ‘operands to the || and && operators ust be convertible to logical scalar values. ‘ So is there any other method that can replace lsqnonlin to solve my problem? Or any corrections, changes to be made in my code to solve this with lsqnonlin? Thanks! Here’s my function file and code.
function Result = myfunc1(a,p,G,m,fraction)
totalconcentration = 0.0000291;
n = 2;
K = exp(-((G + m * fraction)./(8.314*298)));
g_lb = 0;
g_ub = 0.9999;
g =[g_lb g_ub];
monomerconcentration = fzero(@denaturationfun,g);
function y = denaturationfun(x)
y = a.^(-1).*(((a.*x).^(n+1)).*(n.*a.*x-n-1)/((a.*x-1).^2)+a.*x/((a.*x-1).^2))-a.^(n-1).*((x^(n+1)).*(n.*x-n-1)/((x-1).^2))-K.*totalconcentration;
end
Result = p * (1- (monomerconcentration / ( K * totalconcentration )));
end
clc;
clear;
close all;
fractiondata = [0.1505 0.1546 0.1587 0.1628 0.1668 0.1708 0.1748 0.1787 0.1825 0.1864 0.1902 0.194 0.1977 0.2014 0.205 0.2087 0.2123];
DegreeofAggdata = [1 0.9087 0.8658 0.83453 0.79569 0.67979 0.62031 0.53043 0.39722 0.25888 0.15171 0.04759 0.00109 3.20E-04 0.00144 7.77E-04 0];
fun = @(x)DegreeofAggdata – myfunc1(x(1),x(2),x(3),x(4),fractiondata);
x0 = [0.01,0.9,-50000,100000];
lb = [0.00001,0.9,-100000,20000];
ub = [1,1.1,-10000,130000];
x = lsqnonlin(fun,x0,lb,ub); I want to use lsqnonlin analysis to fit a model to two sets of data and obtain values of 4 variables. The function i created contains fzero function which only allows scalar values and i finally got the error ‘operands to the || and && operators ust be convertible to logical scalar values. ‘ So is there any other method that can replace lsqnonlin to solve my problem? Or any corrections, changes to be made in my code to solve this with lsqnonlin? Thanks! Here’s my function file and code.
function Result = myfunc1(a,p,G,m,fraction)
totalconcentration = 0.0000291;
n = 2;
K = exp(-((G + m * fraction)./(8.314*298)));
g_lb = 0;
g_ub = 0.9999;
g =[g_lb g_ub];
monomerconcentration = fzero(@denaturationfun,g);
function y = denaturationfun(x)
y = a.^(-1).*(((a.*x).^(n+1)).*(n.*a.*x-n-1)/((a.*x-1).^2)+a.*x/((a.*x-1).^2))-a.^(n-1).*((x^(n+1)).*(n.*x-n-1)/((x-1).^2))-K.*totalconcentration;
end
Result = p * (1- (monomerconcentration / ( K * totalconcentration )));
end
clc;
clear;
close all;
fractiondata = [0.1505 0.1546 0.1587 0.1628 0.1668 0.1708 0.1748 0.1787 0.1825 0.1864 0.1902 0.194 0.1977 0.2014 0.205 0.2087 0.2123];
DegreeofAggdata = [1 0.9087 0.8658 0.83453 0.79569 0.67979 0.62031 0.53043 0.39722 0.25888 0.15171 0.04759 0.00109 3.20E-04 0.00144 7.77E-04 0];
fun = @(x)DegreeofAggdata – myfunc1(x(1),x(2),x(3),x(4),fractiondata);
x0 = [0.01,0.9,-50000,100000];
lb = [0.00001,0.9,-100000,20000];
ub = [1,1.1,-10000,130000];
x = lsqnonlin(fun,x0,lb,ub); matlab, lsqnonlin, fzero, fit model MATLAB Answers — New Questions
Why does findobj behave different in windows than in unix systems?
Hello,
I am facing something rather curious, I am noticing a behaviour different on Matlab function findobj in Windows(10/11) or Unix ( ubuntu 22).
My issue roots to the search of figures by name, in windows I use the function like this
figHandle = findobj(groot,’Name’,figName);
so providing the figName finds the figure as expected, but running same command under Matlab unix version it returns empty figHandle. I use the Matlab unix version in my CI environment where I found the issue.
Does it rely on lower OS functions that do not behave the same? Can I overcome this issue?
Thanks in advance,
RegardsHello,
I am facing something rather curious, I am noticing a behaviour different on Matlab function findobj in Windows(10/11) or Unix ( ubuntu 22).
My issue roots to the search of figures by name, in windows I use the function like this
figHandle = findobj(groot,’Name’,figName);
so providing the figName finds the figure as expected, but running same command under Matlab unix version it returns empty figHandle. I use the Matlab unix version in my CI environment where I found the issue.
Does it rely on lower OS functions that do not behave the same? Can I overcome this issue?
Thanks in advance,
Regards Hello,
I am facing something rather curious, I am noticing a behaviour different on Matlab function findobj in Windows(10/11) or Unix ( ubuntu 22).
My issue roots to the search of figures by name, in windows I use the function like this
figHandle = findobj(groot,’Name’,figName);
so providing the figName finds the figure as expected, but running same command under Matlab unix version it returns empty figHandle. I use the Matlab unix version in my CI environment where I found the issue.
Does it rely on lower OS functions that do not behave the same? Can I overcome this issue?
Thanks in advance,
Regards findobj MATLAB Answers — New Questions