Month: September 2024
how to reduce ripple
these are the current and voltage values of sepic converter( standalone).
these are the same current and voltages of sepic when connected to the input of grid connected inverter. how can reduce these ripples?these are the current and voltage values of sepic converter( standalone).
these are the same current and voltages of sepic when connected to the input of grid connected inverter. how can reduce these ripples? these are the current and voltage values of sepic converter( standalone).
these are the same current and voltages of sepic when connected to the input of grid connected inverter. how can reduce these ripples? how to reduc ripple in waveform MATLAB Answers — New Questions
How to perform Bonferroni correction on ttest2 comparison of two independent samples?
Hi all!
My question may be simple but I don’t get to perform Bonferroni correction on ttest2 comparison of two random independent samples with equal column number but different row number.
I want to perform ttest2 comparison between each column of my two samples, therefore getting 10 p-values (see example below). But i get the following error "Index in position 1 is invalid. Array indices must be positive integers or logical values".
Once I overcome this error, I would like to perform Bonferroni correction on ttest2 comparison.
So many thanks!!! I’m using Matlab R2022b
% Note that r1 and r2 differ in row number, not column number
r1 = randi(125,200,10); % Random sample 1
r2 = randi(155,100,10); % Random sample 2
% Perform ttest2 comparison, getting 10-pvalues by comparing the 10 columns of r1 and r2
[h,p,ci,stats] = ttest2(r1(i,:),r2(i,:)); % ttest2 comparison of two random, independent samples
results = multcompare(stats,"CriticalValueType","bonferroni") % Bonferroni correction on ttest2Hi all!
My question may be simple but I don’t get to perform Bonferroni correction on ttest2 comparison of two random independent samples with equal column number but different row number.
I want to perform ttest2 comparison between each column of my two samples, therefore getting 10 p-values (see example below). But i get the following error "Index in position 1 is invalid. Array indices must be positive integers or logical values".
Once I overcome this error, I would like to perform Bonferroni correction on ttest2 comparison.
So many thanks!!! I’m using Matlab R2022b
% Note that r1 and r2 differ in row number, not column number
r1 = randi(125,200,10); % Random sample 1
r2 = randi(155,100,10); % Random sample 2
% Perform ttest2 comparison, getting 10-pvalues by comparing the 10 columns of r1 and r2
[h,p,ci,stats] = ttest2(r1(i,:),r2(i,:)); % ttest2 comparison of two random, independent samples
results = multcompare(stats,"CriticalValueType","bonferroni") % Bonferroni correction on ttest2 Hi all!
My question may be simple but I don’t get to perform Bonferroni correction on ttest2 comparison of two random independent samples with equal column number but different row number.
I want to perform ttest2 comparison between each column of my two samples, therefore getting 10 p-values (see example below). But i get the following error "Index in position 1 is invalid. Array indices must be positive integers or logical values".
Once I overcome this error, I would like to perform Bonferroni correction on ttest2 comparison.
So many thanks!!! I’m using Matlab R2022b
% Note that r1 and r2 differ in row number, not column number
r1 = randi(125,200,10); % Random sample 1
r2 = randi(155,100,10); % Random sample 2
% Perform ttest2 comparison, getting 10-pvalues by comparing the 10 columns of r1 and r2
[h,p,ci,stats] = ttest2(r1(i,:),r2(i,:)); % ttest2 comparison of two random, independent samples
results = multcompare(stats,"CriticalValueType","bonferroni") % Bonferroni correction on ttest2 multcompare, bonferroni, ttest2, two independent samples MATLAB Answers — New Questions
When I close the figure or eeglab, the program becomes unresponsive
After updating MacOS to Sonoma 14.1, I noticed that the program becomes unresponsive when I close a figure or eeglab.
I tried reinstalling Matlab, but I still encountered the same issue. I suspect it might be related to the recent update.
Has anyone else experienced this situation?
More information:
Macbook Air M1, 512GB, 8G RAM
Matlab R2023b (Apple silicon)After updating MacOS to Sonoma 14.1, I noticed that the program becomes unresponsive when I close a figure or eeglab.
I tried reinstalling Matlab, but I still encountered the same issue. I suspect it might be related to the recent update.
Has anyone else experienced this situation?
More information:
Macbook Air M1, 512GB, 8G RAM
Matlab R2023b (Apple silicon) After updating MacOS to Sonoma 14.1, I noticed that the program becomes unresponsive when I close a figure or eeglab.
I tried reinstalling Matlab, but I still encountered the same issue. I suspect it might be related to the recent update.
Has anyone else experienced this situation?
More information:
Macbook Air M1, 512GB, 8G RAM
Matlab R2023b (Apple silicon) macos, sonoma, eeglab, figure MATLAB Answers — New Questions
How to solve for 1D non homogenous ODE by Finite element method
I am unable to input the dirichlet condition into this non homogenous ode. Please point out my mistake.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% -u" + u = – 5x + 4 0 < x <= 1 %%%%
%%%% u(0) = 0, u(1) = 2 %%%%
%%%% Exact solution u = (exp(x)*(3*exp(1) + 4))/(exp(2) – 1) – 5*x – (exp(-x)*(3*exp(1) + 4*exp(2)))/(exp(2) – 1) + 4 %%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all;
close all;
format long;
N = 20;
x0 = 0;
xN = 1;
h = 1/N;
for j = 1:N+1
X(j) = x0 + (j-1)*h;
end
f = @(x)(- 5*x +4);
A = zeros(N+1,N+1);
F = zeros(N+1,1);
%%%% Local stiffness matrix %%%%
a = [1/h -1/h ; -1/h 1/h] ;
for i=1:N
phi1 = @(x)(X(i+1)-x)/h; %%%% linear basis function %%%%
phi2 = @(x)(x-X(i))/h; %%%% linear basis function %%%%
f1 = @(x)f(x)*phi1(x); %%%% integrand for load vector %%%%
f2 = @(x)f(x)*phi2(x); %%%% integrand for load vector %%%%
v(1,i) = gauss(f1,X(i),X(i+1),1); %%%% element wise values of
v(2,i) = gauss(f2,X(i),X(i+1),1); %%%% load vector
end
%%%% Assembling %%%%
for i=1:N
A([i i+1],[i i+1]) = A([i i+1],[i i+1]) + a;
F([i i+1],1) = F([i i+1],1) + v([1 2],i);
end
%%%% Dirichlet Boundary condition %%%%
% F(N+1,1) = F(N+1,1)+2;
fullnodes = [1:N+1];
%%%%% Dirichlet boundary condition %%%%%
freenodes=setdiff(fullnodes,[1]);
Uh = zeros(N+1,1);
Uh(N+1,1) = 2;
%%%% Approximate solution %%%%
Uh(freenodes)=A(freenodes,freenodes)F(freenodes,1);
%%%% Exact solution %%%%
U = zeros(N+1,1);
for i =1:N+1
U(i) = (exp(X(i))*(3*exp(1) + 4))/(exp(2) – 1) – 5*X(i) – (exp(-X(i))*(3*exp(1) + 4*exp(2)))/(exp(2) – 1) + 4;
end
error = max(abs(U-Uh));
[U Uh]
plot(X,U,X,Uh,’o’)I am unable to input the dirichlet condition into this non homogenous ode. Please point out my mistake.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% -u" + u = – 5x + 4 0 < x <= 1 %%%%
%%%% u(0) = 0, u(1) = 2 %%%%
%%%% Exact solution u = (exp(x)*(3*exp(1) + 4))/(exp(2) – 1) – 5*x – (exp(-x)*(3*exp(1) + 4*exp(2)))/(exp(2) – 1) + 4 %%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all;
close all;
format long;
N = 20;
x0 = 0;
xN = 1;
h = 1/N;
for j = 1:N+1
X(j) = x0 + (j-1)*h;
end
f = @(x)(- 5*x +4);
A = zeros(N+1,N+1);
F = zeros(N+1,1);
%%%% Local stiffness matrix %%%%
a = [1/h -1/h ; -1/h 1/h] ;
for i=1:N
phi1 = @(x)(X(i+1)-x)/h; %%%% linear basis function %%%%
phi2 = @(x)(x-X(i))/h; %%%% linear basis function %%%%
f1 = @(x)f(x)*phi1(x); %%%% integrand for load vector %%%%
f2 = @(x)f(x)*phi2(x); %%%% integrand for load vector %%%%
v(1,i) = gauss(f1,X(i),X(i+1),1); %%%% element wise values of
v(2,i) = gauss(f2,X(i),X(i+1),1); %%%% load vector
end
%%%% Assembling %%%%
for i=1:N
A([i i+1],[i i+1]) = A([i i+1],[i i+1]) + a;
F([i i+1],1) = F([i i+1],1) + v([1 2],i);
end
%%%% Dirichlet Boundary condition %%%%
% F(N+1,1) = F(N+1,1)+2;
fullnodes = [1:N+1];
%%%%% Dirichlet boundary condition %%%%%
freenodes=setdiff(fullnodes,[1]);
Uh = zeros(N+1,1);
Uh(N+1,1) = 2;
%%%% Approximate solution %%%%
Uh(freenodes)=A(freenodes,freenodes)F(freenodes,1);
%%%% Exact solution %%%%
U = zeros(N+1,1);
for i =1:N+1
U(i) = (exp(X(i))*(3*exp(1) + 4))/(exp(2) – 1) – 5*X(i) – (exp(-X(i))*(3*exp(1) + 4*exp(2)))/(exp(2) – 1) + 4;
end
error = max(abs(U-Uh));
[U Uh]
plot(X,U,X,Uh,’o’) I am unable to input the dirichlet condition into this non homogenous ode. Please point out my mistake.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% -u" + u = – 5x + 4 0 < x <= 1 %%%%
%%%% u(0) = 0, u(1) = 2 %%%%
%%%% Exact solution u = (exp(x)*(3*exp(1) + 4))/(exp(2) – 1) – 5*x – (exp(-x)*(3*exp(1) + 4*exp(2)))/(exp(2) – 1) + 4 %%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all;
close all;
format long;
N = 20;
x0 = 0;
xN = 1;
h = 1/N;
for j = 1:N+1
X(j) = x0 + (j-1)*h;
end
f = @(x)(- 5*x +4);
A = zeros(N+1,N+1);
F = zeros(N+1,1);
%%%% Local stiffness matrix %%%%
a = [1/h -1/h ; -1/h 1/h] ;
for i=1:N
phi1 = @(x)(X(i+1)-x)/h; %%%% linear basis function %%%%
phi2 = @(x)(x-X(i))/h; %%%% linear basis function %%%%
f1 = @(x)f(x)*phi1(x); %%%% integrand for load vector %%%%
f2 = @(x)f(x)*phi2(x); %%%% integrand for load vector %%%%
v(1,i) = gauss(f1,X(i),X(i+1),1); %%%% element wise values of
v(2,i) = gauss(f2,X(i),X(i+1),1); %%%% load vector
end
%%%% Assembling %%%%
for i=1:N
A([i i+1],[i i+1]) = A([i i+1],[i i+1]) + a;
F([i i+1],1) = F([i i+1],1) + v([1 2],i);
end
%%%% Dirichlet Boundary condition %%%%
% F(N+1,1) = F(N+1,1)+2;
fullnodes = [1:N+1];
%%%%% Dirichlet boundary condition %%%%%
freenodes=setdiff(fullnodes,[1]);
Uh = zeros(N+1,1);
Uh(N+1,1) = 2;
%%%% Approximate solution %%%%
Uh(freenodes)=A(freenodes,freenodes)F(freenodes,1);
%%%% Exact solution %%%%
U = zeros(N+1,1);
for i =1:N+1
U(i) = (exp(X(i))*(3*exp(1) + 4))/(exp(2) – 1) – 5*X(i) – (exp(-X(i))*(3*exp(1) + 4*exp(2)))/(exp(2) – 1) + 4;
end
error = max(abs(U-Uh));
[U Uh]
plot(X,U,X,Uh,’o’) finite element method MATLAB Answers — New Questions
Why the Kf_LMax value is increased beyond its limits. Is their is any logical error Kindly help me out .
Why the Kf_LMax value is increased beyond its limits. Is their is any logical error Kindly help me out .
% Define parameters
Kf_Max = 100; % maximum forward rate
RLC = [0.1, 0.5, 10, 5, 10, 1]; % RLC values
TauKf_ON = -0.01; % TauKf_ON
TauKf_OFF = -0.01; % TauKf_OFF
PhaseTimes = [0, 500, 1000, 2000, 3000, 4000, 5000]; % phase times (each row defines a phase)
% Generate time vector
t = 0:0.01:5000;
% Call the function to compute receptor concentrations and Kf
[ Kf_LMax] = Kf_Cal(Kf_Max, RLC, TauKf_ON, TauKf_OFF, PhaseTimes, t);
% Plotting
figure;
% Plot Kf_LMax
plot(t, Kf_LMax, ‘b’, ‘LineWidth’, 1.5);
title(‘Kf_LMax over Time’);
xlabel(‘Time’);
ylabel(‘Kf_LMax’);
grid on;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [ Kf_LMax] = Kf_Cal(Kf_Max, RLC, TauKf_ON, TauKf_OFF, PhaseTimes, t)
% Initialize output variables
Kf_LMax = zeros(size(t));
% Calculate Kf_L for each time step
for i = 1:length(t)
Kf_LMax(i) = calculate_kf(t(i), PhaseTimes, Kf_Max, RLC, TauKf_ON, TauKf_OFF);
end
% Nested function for calculating Kf_L based on time
function Kf_L = calculate_kf(t_current, PhaseTimes, Kf_Max, RLC, TauKf_ON, TauKf_OFF)
% Calculate maximum Kf_L based on RLC values using Element wise
% division
Kf_LMax_values = Kf_Max * (RLC ./ (1 + RLC));
% Default Kf_L to the maximum value of the first phase
Kf_L = Kf_LMax_values(1);
% Number of phases
num_phases = numel(RLC);
% Iterate through each phase to determine the current phase based on time
for j = 1:num_phases
T_start = PhaseTimes(j); % Start time of the current phase
if j < num_phases
T_end = PhaseTimes(j + 1); % End time of the current phase
else
T_end = inf; % Handle last phase separately
end
% Check if the current time t_current is within the current phase
if t_current >= T_start && t_current < T_end
if j == 1
% For the first phase, use the maximum value directly
Kf_L = Kf_LMax_values(j);
else
% Time at the end of the previous phase
% prev_end = PhaseTimes(j – 1);
if j < num_phases
% Check RLC conditions and compute Kf_L
if RLC(j – 1) < RLC(j) && RLC(j) > RLC(j + 1)
% Peak condition
Kf_endA = Kf_LMax_values(j) – (Kf_LMax_values(j) – Kf_LMax_values(j – 1)) * exp(TauKf_ON * (t_current – T_start));
Kf_L = Kf_LMax_values(j) + (Kf_endA – Kf_LMax_values(j – 1)) *exp(TauKf_OFF * ( t_current – T_start));
elseif RLC(j – 1) < RLC(j) && RLC(j) < RLC(j + 1)
% Increasing RLC condition
Kf_endB = Kf_LMax_values(j) – (Kf_LMax_values(j) – Kf_LMax_values(j – 1)) * exp(TauKf_ON * (t_current – T_start));
Kf_L = Kf_LMax_values(j) + (Kf_endB – Kf_LMax_values(j – 1)) *exp(TauKf_OFF * (t_current – T_start));
elseif RLC(j – 1) > RLC(j) && RLC(j) < RLC(j + 1)
% Decreasing RLC condition
Kf_endC = Kf_LMax_values(j) – (Kf_LMax_values(j) – Kf_LMax_values(j – 1)) * exp(TauKf_ON * (t_current – T_start));
Kf_L = Kf_LMax_values(j) + (Kf_endC – Kf_LMax_values(j – 1)) * exp(TauKf_OFF * (t_current – T_start ));
elseif RLC(j – 1) > RLC(j) && RLC(j) >= RLC(j + 1)
% Flat or decreasing RLC condition
Kf_endD = Kf_LMax_values(j) – (Kf_LMax_values(j) – Kf_LMax_values(j – 1)) * exp(TauKf_ON * (t_current – T_start));
Kf_L = Kf_LMax_values(j) + (Kf_endD – Kf_LMax_values(j – 1)) * exp(TauKf_OFF * (t_current – T_start ));
end
else
% % % Handling for the last phase
if RLC(j – 1) < RLC(j)
Kf_end1 = Kf_LMax_values(j) – (Kf_LMax_values(j) – Kf_LMax_values(j – 1)) * exp(TauKf_ON * (t_current – T_start) Kf_L = Kf_LMax_values(j) + (Kf_end1 – Kf_LMax_values(j – 1)) * exp(TauKf_OFF * (t_current – T_start));
elseif RLC(j – 1) > RLC(j)
Kf_end2 = Kf_LMax_values(j) – (Kf_LMax_values(j) – Kf_LMax_values(j – 1)) * exp(TauKf_ON * (t_current – T_start));
Kf_L = Kf_LMax_values(j) + (Kf_end2 – Kf_LMax_values(j – 1)) * exp(TauKf_OFF * (t_current – T_start));
end
end
end
return; % Exit the function after finding the correct phase
end
end
end
endWhy the Kf_LMax value is increased beyond its limits. Is their is any logical error Kindly help me out .
% Define parameters
Kf_Max = 100; % maximum forward rate
RLC = [0.1, 0.5, 10, 5, 10, 1]; % RLC values
TauKf_ON = -0.01; % TauKf_ON
TauKf_OFF = -0.01; % TauKf_OFF
PhaseTimes = [0, 500, 1000, 2000, 3000, 4000, 5000]; % phase times (each row defines a phase)
% Generate time vector
t = 0:0.01:5000;
% Call the function to compute receptor concentrations and Kf
[ Kf_LMax] = Kf_Cal(Kf_Max, RLC, TauKf_ON, TauKf_OFF, PhaseTimes, t);
% Plotting
figure;
% Plot Kf_LMax
plot(t, Kf_LMax, ‘b’, ‘LineWidth’, 1.5);
title(‘Kf_LMax over Time’);
xlabel(‘Time’);
ylabel(‘Kf_LMax’);
grid on;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [ Kf_LMax] = Kf_Cal(Kf_Max, RLC, TauKf_ON, TauKf_OFF, PhaseTimes, t)
% Initialize output variables
Kf_LMax = zeros(size(t));
% Calculate Kf_L for each time step
for i = 1:length(t)
Kf_LMax(i) = calculate_kf(t(i), PhaseTimes, Kf_Max, RLC, TauKf_ON, TauKf_OFF);
end
% Nested function for calculating Kf_L based on time
function Kf_L = calculate_kf(t_current, PhaseTimes, Kf_Max, RLC, TauKf_ON, TauKf_OFF)
% Calculate maximum Kf_L based on RLC values using Element wise
% division
Kf_LMax_values = Kf_Max * (RLC ./ (1 + RLC));
% Default Kf_L to the maximum value of the first phase
Kf_L = Kf_LMax_values(1);
% Number of phases
num_phases = numel(RLC);
% Iterate through each phase to determine the current phase based on time
for j = 1:num_phases
T_start = PhaseTimes(j); % Start time of the current phase
if j < num_phases
T_end = PhaseTimes(j + 1); % End time of the current phase
else
T_end = inf; % Handle last phase separately
end
% Check if the current time t_current is within the current phase
if t_current >= T_start && t_current < T_end
if j == 1
% For the first phase, use the maximum value directly
Kf_L = Kf_LMax_values(j);
else
% Time at the end of the previous phase
% prev_end = PhaseTimes(j – 1);
if j < num_phases
% Check RLC conditions and compute Kf_L
if RLC(j – 1) < RLC(j) && RLC(j) > RLC(j + 1)
% Peak condition
Kf_endA = Kf_LMax_values(j) – (Kf_LMax_values(j) – Kf_LMax_values(j – 1)) * exp(TauKf_ON * (t_current – T_start));
Kf_L = Kf_LMax_values(j) + (Kf_endA – Kf_LMax_values(j – 1)) *exp(TauKf_OFF * ( t_current – T_start));
elseif RLC(j – 1) < RLC(j) && RLC(j) < RLC(j + 1)
% Increasing RLC condition
Kf_endB = Kf_LMax_values(j) – (Kf_LMax_values(j) – Kf_LMax_values(j – 1)) * exp(TauKf_ON * (t_current – T_start));
Kf_L = Kf_LMax_values(j) + (Kf_endB – Kf_LMax_values(j – 1)) *exp(TauKf_OFF * (t_current – T_start));
elseif RLC(j – 1) > RLC(j) && RLC(j) < RLC(j + 1)
% Decreasing RLC condition
Kf_endC = Kf_LMax_values(j) – (Kf_LMax_values(j) – Kf_LMax_values(j – 1)) * exp(TauKf_ON * (t_current – T_start));
Kf_L = Kf_LMax_values(j) + (Kf_endC – Kf_LMax_values(j – 1)) * exp(TauKf_OFF * (t_current – T_start ));
elseif RLC(j – 1) > RLC(j) && RLC(j) >= RLC(j + 1)
% Flat or decreasing RLC condition
Kf_endD = Kf_LMax_values(j) – (Kf_LMax_values(j) – Kf_LMax_values(j – 1)) * exp(TauKf_ON * (t_current – T_start));
Kf_L = Kf_LMax_values(j) + (Kf_endD – Kf_LMax_values(j – 1)) * exp(TauKf_OFF * (t_current – T_start ));
end
else
% % % Handling for the last phase
if RLC(j – 1) < RLC(j)
Kf_end1 = Kf_LMax_values(j) – (Kf_LMax_values(j) – Kf_LMax_values(j – 1)) * exp(TauKf_ON * (t_current – T_start) Kf_L = Kf_LMax_values(j) + (Kf_end1 – Kf_LMax_values(j – 1)) * exp(TauKf_OFF * (t_current – T_start));
elseif RLC(j – 1) > RLC(j)
Kf_end2 = Kf_LMax_values(j) – (Kf_LMax_values(j) – Kf_LMax_values(j – 1)) * exp(TauKf_ON * (t_current – T_start));
Kf_L = Kf_LMax_values(j) + (Kf_end2 – Kf_LMax_values(j – 1)) * exp(TauKf_OFF * (t_current – T_start));
end
end
end
return; % Exit the function after finding the correct phase
end
end
end
end Why the Kf_LMax value is increased beyond its limits. Is their is any logical error Kindly help me out .
% Define parameters
Kf_Max = 100; % maximum forward rate
RLC = [0.1, 0.5, 10, 5, 10, 1]; % RLC values
TauKf_ON = -0.01; % TauKf_ON
TauKf_OFF = -0.01; % TauKf_OFF
PhaseTimes = [0, 500, 1000, 2000, 3000, 4000, 5000]; % phase times (each row defines a phase)
% Generate time vector
t = 0:0.01:5000;
% Call the function to compute receptor concentrations and Kf
[ Kf_LMax] = Kf_Cal(Kf_Max, RLC, TauKf_ON, TauKf_OFF, PhaseTimes, t);
% Plotting
figure;
% Plot Kf_LMax
plot(t, Kf_LMax, ‘b’, ‘LineWidth’, 1.5);
title(‘Kf_LMax over Time’);
xlabel(‘Time’);
ylabel(‘Kf_LMax’);
grid on;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [ Kf_LMax] = Kf_Cal(Kf_Max, RLC, TauKf_ON, TauKf_OFF, PhaseTimes, t)
% Initialize output variables
Kf_LMax = zeros(size(t));
% Calculate Kf_L for each time step
for i = 1:length(t)
Kf_LMax(i) = calculate_kf(t(i), PhaseTimes, Kf_Max, RLC, TauKf_ON, TauKf_OFF);
end
% Nested function for calculating Kf_L based on time
function Kf_L = calculate_kf(t_current, PhaseTimes, Kf_Max, RLC, TauKf_ON, TauKf_OFF)
% Calculate maximum Kf_L based on RLC values using Element wise
% division
Kf_LMax_values = Kf_Max * (RLC ./ (1 + RLC));
% Default Kf_L to the maximum value of the first phase
Kf_L = Kf_LMax_values(1);
% Number of phases
num_phases = numel(RLC);
% Iterate through each phase to determine the current phase based on time
for j = 1:num_phases
T_start = PhaseTimes(j); % Start time of the current phase
if j < num_phases
T_end = PhaseTimes(j + 1); % End time of the current phase
else
T_end = inf; % Handle last phase separately
end
% Check if the current time t_current is within the current phase
if t_current >= T_start && t_current < T_end
if j == 1
% For the first phase, use the maximum value directly
Kf_L = Kf_LMax_values(j);
else
% Time at the end of the previous phase
% prev_end = PhaseTimes(j – 1);
if j < num_phases
% Check RLC conditions and compute Kf_L
if RLC(j – 1) < RLC(j) && RLC(j) > RLC(j + 1)
% Peak condition
Kf_endA = Kf_LMax_values(j) – (Kf_LMax_values(j) – Kf_LMax_values(j – 1)) * exp(TauKf_ON * (t_current – T_start));
Kf_L = Kf_LMax_values(j) + (Kf_endA – Kf_LMax_values(j – 1)) *exp(TauKf_OFF * ( t_current – T_start));
elseif RLC(j – 1) < RLC(j) && RLC(j) < RLC(j + 1)
% Increasing RLC condition
Kf_endB = Kf_LMax_values(j) – (Kf_LMax_values(j) – Kf_LMax_values(j – 1)) * exp(TauKf_ON * (t_current – T_start));
Kf_L = Kf_LMax_values(j) + (Kf_endB – Kf_LMax_values(j – 1)) *exp(TauKf_OFF * (t_current – T_start));
elseif RLC(j – 1) > RLC(j) && RLC(j) < RLC(j + 1)
% Decreasing RLC condition
Kf_endC = Kf_LMax_values(j) – (Kf_LMax_values(j) – Kf_LMax_values(j – 1)) * exp(TauKf_ON * (t_current – T_start));
Kf_L = Kf_LMax_values(j) + (Kf_endC – Kf_LMax_values(j – 1)) * exp(TauKf_OFF * (t_current – T_start ));
elseif RLC(j – 1) > RLC(j) && RLC(j) >= RLC(j + 1)
% Flat or decreasing RLC condition
Kf_endD = Kf_LMax_values(j) – (Kf_LMax_values(j) – Kf_LMax_values(j – 1)) * exp(TauKf_ON * (t_current – T_start));
Kf_L = Kf_LMax_values(j) + (Kf_endD – Kf_LMax_values(j – 1)) * exp(TauKf_OFF * (t_current – T_start ));
end
else
% % % Handling for the last phase
if RLC(j – 1) < RLC(j)
Kf_end1 = Kf_LMax_values(j) – (Kf_LMax_values(j) – Kf_LMax_values(j – 1)) * exp(TauKf_ON * (t_current – T_start) Kf_L = Kf_LMax_values(j) + (Kf_end1 – Kf_LMax_values(j – 1)) * exp(TauKf_OFF * (t_current – T_start));
elseif RLC(j – 1) > RLC(j)
Kf_end2 = Kf_LMax_values(j) – (Kf_LMax_values(j) – Kf_LMax_values(j – 1)) * exp(TauKf_ON * (t_current – T_start));
Kf_L = Kf_LMax_values(j) + (Kf_end2 – Kf_LMax_values(j – 1)) * exp(TauKf_OFF * (t_current – T_start));
end
end
end
return; % Exit the function after finding the correct phase
end
end
end
end graph MATLAB Answers — New Questions
Custom Forms do not sync in Outlook with O365
Hello,
In my company, we use the Developer Tool to create custom forms for Contacts and Tasks, which generate new pages in the contact items within Outlook. We use these custom fields to keep our contacts updated, filter them, and perform various other tasks. These items are saved in Outlook as IPM.Contact.[custom_name] in the “Custom Forms Library” folder.
The issue we’re encountering is that, although our contacts are stored in our contact list, when they call us through Teams, the contacts do not synchronize, so we are unable to identify the caller. Additionally, when we use Outlook Web, we cannot see any contacts that were not created using the default Contact or Task items in Outlook. Any items created with the Developer Tool do not synchronize.
We suspect that the problem might be related to one of the Exchange connectors, which could be configured to only synchronize contacts that use the default M365 form. However, we are unsure how to modify this setting.
Thank you!
Hello,In my company, we use the Developer Tool to create custom forms for Contacts and Tasks, which generate new pages in the contact items within Outlook. We use these custom fields to keep our contacts updated, filter them, and perform various other tasks. These items are saved in Outlook as IPM.Contact.[custom_name] in the “Custom Forms Library” folder.The issue we’re encountering is that, although our contacts are stored in our contact list, when they call us through Teams, the contacts do not synchronize, so we are unable to identify the caller. Additionally, when we use Outlook Web, we cannot see any contacts that were not created using the default Contact or Task items in Outlook. Any items created with the Developer Tool do not synchronize.We suspect that the problem might be related to one of the Exchange connectors, which could be configured to only synchronize contacts that use the default M365 form. However, we are unsure how to modify this setting. Thank you! Read More
How can I accommodate payment plans where the amounts differ per term?
When selling our SaaS solution we typically have a 3 year contract with annual payments. We always use private offers. Generally the contracts have 3 equal payments. But in some cases the payment amount differ per term.
At this moment I need to create multiple private offers to accommodate this. In some cases I have to wait two years to have the customer activate their last subscription.
For example, a payment schedule
Year 1 = 100.000 Year / Year 2 = 150.000 / Year 3 = 250.000
This would result into 3 Private Offers with different starting dates which shows to be confusing for our customers.
How can I make a Private Offer with 1 plan where the amounts differ per term(year)?
When selling our SaaS solution we typically have a 3 year contract with annual payments. We always use private offers. Generally the contracts have 3 equal payments. But in some cases the payment amount differ per term. At this moment I need to create multiple private offers to accommodate this. In some cases I have to wait two years to have the customer activate their last subscription. For example, a payment schedule Year 1 = 100.000 Year / Year 2 = 150.000 / Year 3 = 250.000 This would result into 3 Private Offers with different starting dates which shows to be confusing for our customers. How can I make a Private Offer with 1 plan where the amounts differ per term(year)? Read More
Unable to Access Windows server remotely
Hello, we are hosting a VM on a local computer using Hyper-V. we normally access the VM and work on it using windows remote desktop. This morning, we are tried connecting to the VM and it is not recognizing any of our passwords. I have logged on to the VM through the Host computer, restarted the VM, checked to see that the remote desktop services is running and they are. but yet I can’t seem to resolve the issue. What could be the reason or what can I check to resolve this issue.
Hello, we are hosting a VM on a local computer using Hyper-V. we normally access the VM and work on it using windows remote desktop. This morning, we are tried connecting to the VM and it is not recognizing any of our passwords. I have logged on to the VM through the Host computer, restarted the VM, checked to see that the remote desktop services is running and they are. but yet I can’t seem to resolve the issue. What could be the reason or what can I check to resolve this issue. Read More
Update implementation date based on quarter on list.
Hello all,
I need your support regarding the below issue. I have an approval flow list that is used for internal approval of the account team change.
It is required that the changes to be implemented and team notified on the next Quarter.
So if the request date is today the notification should go to the team for implementation on the first day of next quarter. EX 01.October.
Thank you!
Hello all, I need your support regarding the below issue. I have an approval flow list that is used for internal approval of the account team change.It is required that the changes to be implemented and team notified on the next Quarter.So if the request date is today the notification should go to the team for implementation on the first day of next quarter. EX 01.October. Thank you! Read More
Help needed to create a VBA macro for moving data to and from other worksheets
Hi all,
I’m trying to create a project workload workbook which has a list of ongoing projects in one worksheet and a separate worksheet for completed projects. I’d like to automatically move a project from the ‘ongoing’ sheet to the ‘completed’ sheet by simply selecting ‘completed’ in the status column. I’d like for this project to move onto the next available row in the ‘completed’ worksheet. I’d also like to be able to move the project back into ‘ongoing’ sheet should the status “completed” have been selected in error.
Please can anyone help me write the correct VBA code to do this? Please find below code which I’ve recently attempted but found it isn’t triggered when selecting the project status (I have to run the macro manually) and when I do, it either moves the project data onto a random row (albeit on the correct sheet), or throws up the VBA window highlighting a section of the code with no explanation as to why it’s an issue!
Any help will be very much appreciated.
Many thanks in advance, Abi.
‘Module Code attempted (but does not work!):’
Sub MoveBasedOnValue()
Dim xRg As Range
Dim xCell As Range
Dim A As Long
Dim B As Long
Dim C As Long
A = Worksheets(“Ongoing Mechanical Projects”).UsedRange.Rows.Count
B = Worksheets(“Completed Schemes 2024-2025”).UsedRange.Rows.Count
If B = 1 Then
If Application.WorksheetFunction.CountA(Worksheets(“Completed Schemes 2024-2025”).UsedRange) = 0 Then B = 0
End If
Set xRg = Worksheets(“Ongoing Mechanical Projects”).Range(“L:L” & A)
On Error Resume Next
Application.ScreenUpdating = False
For C = 1 To xRg.Count
If CStr(xRg(C).Value) = “Completed” Then
xRg(C).EntireRow.Copy Destination:=Worksheets(“Completed Schemes 2024-2025”).Range(“A” & B + 1)
xRg(C).EntireRow.Delete
If CStr(xRg(C).Value) = “Completed” Then
C = C – 1
End If
B = B + 1
End If
Next
Application.ScreenUpdating = True
End Sub
‘Sheet Code attempted (but does not work!):’
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Z As Long
Dim xVal As String
On Error Resume Next
If Intersect(Target, Range(“L:L”)) Is Nothing Then
Application.EnableEvents = False
For Z = 1 To Target.Count
If Target(Z).Value > 0 Then
Call MoveBasedOnValue
End If
Next
Application.EnableEvents = True
End If
End Sub
Hi all, I’m trying to create a project workload workbook which has a list of ongoing projects in one worksheet and a separate worksheet for completed projects. I’d like to automatically move a project from the ‘ongoing’ sheet to the ‘completed’ sheet by simply selecting ‘completed’ in the status column. I’d like for this project to move onto the next available row in the ‘completed’ worksheet. I’d also like to be able to move the project back into ‘ongoing’ sheet should the status “completed” have been selected in error. Please can anyone help me write the correct VBA code to do this? Please find below code which I’ve recently attempted but found it isn’t triggered when selecting the project status (I have to run the macro manually) and when I do, it either moves the project data onto a random row (albeit on the correct sheet), or throws up the VBA window highlighting a section of the code with no explanation as to why it’s an issue! Any help will be very much appreciated. Many thanks in advance, Abi.’Module Code attempted (but does not work!):’
Sub MoveBasedOnValue()
Dim xRg As Range
Dim xCell As Range
Dim A As Long
Dim B As Long
Dim C As Long
A = Worksheets(“Ongoing Mechanical Projects”).UsedRange.Rows.Count
B = Worksheets(“Completed Schemes 2024-2025”).UsedRange.Rows.Count
If B = 1 Then
If Application.WorksheetFunction.CountA(Worksheets(“Completed Schemes 2024-2025”).UsedRange) = 0 Then B = 0
End If
Set xRg = Worksheets(“Ongoing Mechanical Projects”).Range(“L:L” & A)
On Error Resume Next
Application.ScreenUpdating = False
For C = 1 To xRg.Count
If CStr(xRg(C).Value) = “Completed” Then
xRg(C).EntireRow.Copy Destination:=Worksheets(“Completed Schemes 2024-2025”).Range(“A” & B + 1)
xRg(C).EntireRow.Delete
If CStr(xRg(C).Value) = “Completed” Then
C = C – 1
End If
B = B + 1
End If
Next
Application.ScreenUpdating = True
End Sub
‘Sheet Code attempted (but does not work!):’
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Z As Long
Dim xVal As String
On Error Resume Next
If Intersect(Target, Range(“L:L”)) Is Nothing Then
Application.EnableEvents = False
For Z = 1 To Target.Count
If Target(Z).Value > 0 Then
Call MoveBasedOnValue
End If
Next
Application.EnableEvents = True
End If
End Sub Read More
Windows 10 ISO Download Link for creating Windows 10 bootable USB?
My Windows 10 PC was crashed and can’t get into the desktop. I need to download Windows 10 ISO image before starting to create a Windows 10 bootable USB. I go to the Windows 10 software download page and can’t find the Windows 10 download link from Edge browser. The download link points to MediaCreationTool_22H2.exe, which is unable to open on my Mac.
Currently, I am on a MacBook Pro M2. Please let me know where to download Windows 10 ISO image.
Thank you
My Windows 10 PC was crashed and can’t get into the desktop. I need to download Windows 10 ISO image before starting to create a Windows 10 bootable USB. I go to the Windows 10 software download page and can’t find the Windows 10 download link from Edge browser. The download link points to MediaCreationTool_22H2.exe, which is unable to open on my Mac. Currently, I am on a MacBook Pro M2. Please let me know where to download Windows 10 ISO image. Thank you Read More
Availabilty of the announced feature : Scoped and targeted device clean-up rule
Hi,
I’d like to know if the announced feature “Scoped and targeted device clean-up rule” will be available without add-ons in Intune Management.
And is there some specs somewhere about what will contain this feature.
Thanks
Hi,I’d like to know if the announced feature “Scoped and targeted device clean-up rule” will be available without add-ons in Intune Management. And is there some specs somewhere about what will contain this feature. Thanks Read More
I’m unable to execute powershell command in SharePoint
When I execute the PowerShell command, I get a sign-in error. I have tested this in a couple of SharePoint tenants, but I’m unable to run the script. Also, previously, these scripts were working fine.
Unable to execute the “Connect-PnPOnline” command.
Please someone help with this.
When I execute the PowerShell command, I get a sign-in error. I have tested this in a couple of SharePoint tenants, but I’m unable to run the script. Also, previously, these scripts were working fine. Unable to execute the “Connect-PnPOnline” command. Please someone help with this. Read More
Akamai usecase
Hi Team,
Someone having log format for Akamai parser. I need to develop some usecase for Akamai but not having logs. So need to know about logs so can create some hypothetical usecase.
Hi Team, Someone having log format for Akamai parser. I need to develop some usecase for Akamai but not having logs. So need to know about logs so can create some hypothetical usecase. Read More
How to save money on Azure Compute with Savings Plans
Introduction
If you are an enterprise customer who uses Azure for your compute needs, you might be looking for ways to optimize your spending and reduce your costs. One of the features that can help you achieve this goal is Savings Plans for Compute Insights, a flexible and easy way to save up to 65% on your compute costs by committing to a consistent amount of usage for a one-year or three-year term[1].
In this article, we will explain everything you need to know about savings plans for Compute Insights, including how they work, how they compare to reserved instances, how to use them at different levels, how to distribute the costs, and how to leverage Azure Advisor recommendations. By reading this article, you will be able to make informed decisions about whether savings plans are right for you and how to use them effectively.
What are savings plans and how do they work?
Savings Plans are a pricing model that allows you to save money on your compute costs by committing to a certain amount of usage per hour for a one-year or three-year term[2]. You can choose to pay for your savings plans monthly or upfront, and you can apply them to any eligible compute resource in Azure, such as virtual machines, Azure Kubernetes Service, Azure App Service, Azure Functions, and more.
The amount of usage you commit to is called the hourly commitment, and it is measured in dollars per hour[3]. For example, if you commit to $5 per hour for a one-year term, you will pay $5 per hour for any eligible compute usage in Azure, regardless of the region, size, or operating system of the resource. If your usage exceeds your commitment, you will pay the regular pay-as-you-go rates for the excess usage. If your usage is lower than your commitment, you will still pay the committed amount, but you can use the unused portion for future usage within the term.
Figure 1 Hourly spend distribution of compute savings plan usage
Savings plans are different from reserved instances, which are another way to save money on Azure compute by pre-purchasing a specific resource type for a one-year or three-year term. Reservations offer a higher discount rate than Savings Plans, but they are less flexible and more complex to manage[4]. Reservations are tied to a specific region, size, and operating system, and they require you to exchange or cancel them if you want to change your resource configuration[5]. Savings plans, on the other hand, are not tied to any specific resource type, and they automatically apply to any eligible compute usage in Azure, giving you more flexibility and simplicity.
One of the factors that you need to consider before purchasing a savings plan is your existing Microsoft Azure Consumption Commitment (MACC) discount, if you have one[6]. MACC is a discount program that offers you a lower pay-as-you-go rate for your Azure usage, based on your annual commitment and upfront payment. MACC discounts do not stack with savings plan discounts, so you need to compare the two options and choose the one that gives you the best savings. For example, if you have a MACC discount of 5% for your Azure usage, and you purchase a savings plan that offers you a 30% discount for your eligible compute usage, you will only get the 30% discount for the compute usage, and the 5% discount for the rest of the usage. You will not get a 35% discount for the compute usage. This example is for illustration purpose only, and the actual MACC discounts may vary depending on your individual negotiation and commitment.
Another factor that you need to consider before purchasing a savings plan is that it is a 24/7 model, which means that you will pay for your savings plan regardless of whether your compute resources are running or not. This is similar to reserved instances, which also charge you for the entire term, even if you shut down your resources. However, the difference is that savings plans are more flexible and can apply to different resources, whereas reserved instances are fixed and can only apply to the specific resource type that you purchased. Therefore, you need to estimate your usage and commitment carefully, and make sure that you can utilize your savings plan as much as possible. If you have automated shutdown patterns for your resources, you need to be aware that you cannot pick individual hours to use your savings plan, and that you will still pay for the hours that your resources are not running[7].
How to use savings plans at different levels?
Savings plans can be used at different levels in Azure, depending on your organizational structure and needs. You can purchase and manage savings plans at the subscription level, the billing account level, the management group level, or the resource group level[8].
If you purchase savings plans at the subscription level, they will only apply to the eligible compute usage within that subscription. This is the simplest and most granular way to use savings plans, as you can easily track and control your usage and costs. However, this option might not be suitable for customers who have multiple subscriptions or who want to share savings plans across different teams or departments.
If you purchase savings plans at the billing account level, they will apply to the eligible compute usage across all the subscriptions within that billing account. This is a more flexible and efficient way to use savings plans, as you can optimize your spending and utilization across multiple subscriptions. However, this option might not be suitable for customers who have multiple billing accounts or who want to have more visibility and accountability for their usage and costs.
If you purchase savings plans at the management group level, they will apply to the eligible compute usage across all the subscriptions within that management group. This is the most scalable and comprehensive way to use savings plans, as you can leverage the hierarchical structure of management groups to organize and govern your savings plans across your entire organization. However, this option might not be suitable for customers who have a flat or simple organizational structure or who want to have more granularity and flexibility for their usage and costs.
If you purchase savings plans at the resource group level, they will only apply to the eligible compute usage within that resource group. This is a more targeted and specific way to use savings plans, as you can align your Savings Plans with your resource groups, which are logical containers for your resources. However, this option might not be suitable for customers who have multiple resource groups or who want to have more scope and diversity for their usage and costs.
Microsoft recommends that you use savings plans at the level that best suits your organizational needs and goals. You can also use a combination of different levels to achieve the optimal balance of flexibility and efficiency. For example, you can use savings plans at the management group level for your baseline usage, and use savings plans at the subscription level or the resource group level for your variable or project-based usage.
How to distribute the costs for savings plans?
One of the challenges of using savings plans at the billing account level or the management group level is how to distribute the costs for savings plans among the different subscriptions or teams that benefit from them. This is especially important if you want to implement a showback or chargeback model for your internal accounting or budgeting purposes.
When you purchase a savings plan, you cannot choose which resources or subscriptions will use the savings plan. Azure automatically applies the savings plan to the resources or subscriptions that have the highest eligible compute usage and the highest pay-as-you-go rates, so that you can maximize your savings[9]. For example, if you have a savings plan of $5 per hour at the billing account level, and you have three resources with eligible compute usage of 4, 3, and 2 CPU hours per hour respectively, and pay-as-you-go rates of $1.5, $1.2, and $1 per CPU hour respectively, then Azure will apply the savings plan to the first two resources, and you will pay $2 per hour for the third resource at the pay-as-you-go rate.
If you want to distribute the costs for savings plans among the different subscriptions or teams that use them, you have two main options: showback or chargeback[10]. Showback is a method of reporting the costs for savings plans to the different subscriptions or teams, without actually billing them. This is useful for increasing the visibility and awareness of the costs and savings for savings plans, and for encouraging the optimal usage and allocation of resources. Chargeback is a method of billing the costs for savings plans to the different subscriptions or teams, based on their actual usage or a predefined allocation[11]. This is useful for implementing a fair and accurate cost recovery model, and for incentivizing the efficient and responsible use of resources.
To implement either showback or chargeback, you can use tags to identify and group the resources or subscriptions that use savings plans. Tags are key-value pairs that you can assign to any resource or subscription in Azure, and that you can use to filter and analyze your costs and savings for savings plans[12]. For example, you can tag your resources or subscriptions with the name of the team, project, or department that they belong to, and then use Cost analysis in Microsoft Cost Management to view and report the costs and savings for savings plans by tag. However, you cannot tag a Savings Plan itself, as it is not a resource, but a pricing model.
You can also use the Azure portal or the API to see which resources or subscriptions are using a savings plan, and how much they are saving[13]. In the Azure portal, you can go to the savings plans blade, and select the savings plan that you want to view[14]. You will see the details of the savings plan, such as the term, the commitment, the payment option, and the expiration date. You will also see the utilization and savings of the savings plan, and the breakdown by resource type, region, and subscription. You can also export the data to a CSV file for further analysis. Alternatively, you can use the API to query the savings plan usage and savings data programmatically[15].
How to use Azure Advisor recommendations for savings plans?
Azure Advisor is a free service that provides personalized and actionable recommendations to help you optimize your Azure resources and services[16]. One of the recommendations that Azure Advisor provides is Savings Plans for Compute Insights, which helps you identify the optimal amount of savings plans to purchase based on your historical usage and projected savings[17].
To use Azure Advisor recommendations for savings plans, you need to follow these steps:
Go to the Azure Advisor dashboard and select the Cost tab.
Review the Savings Plans for Compute Insights recommendation, which shows you the potential savings, the hourly commitment, the term, and the payment option for the recommended savings plan.
Adjust the lookback period, which is the time range that Azure Advisor uses to analyze your usage and calculate your recommendation. You can choose from 7, 30, 60, or 90 days.
Click on Purchase savings plan to go to the Azure portal and complete the purchase process.
Factors to consider before purchasing a savings plan
Before you purchase a savings plan based on the Azure Advisor recommendation or your own estimation, you should also consider some factors that might affect your decision, such as:
You cannot cancel your savings plans once you purchase them, so you should be confident about your usage and commitment before you buy them[18].
You need to calculate your break-even point, which is the minimum amount of usage that you need to achieve to make your savings plans worthwhile. You can use the Azure Pricing Calculator to estimate your break-even point[19].
You need to monitor and manage your savings plans utilization and performance, and adjust your usage or purchase additional savings plans as needed. You can use the Microsoft Cost Management dashboard and reports to track and optimize your savings plans. You can also use Azure Monitor to monitor the CPU metrics and usage of your compute resources, and to set up alerts and notifications for any anomalies or issues[20].
As an example, if you purchase a savings plan of $5 per hour for a one-year term, and you pay monthly, you will pay $3,600 per month for your savings plan, regardless of your usage. This is because you will pay $5 per hour for 24 hours a day for 30 days a month. If you pay upfront, you will pay $43,200 for the entire term, which is the same as paying $3,600 per month for 12 months. This is the total cost of your savings plan, and it does not include the cost of any other Azure services or resources that you use. You can compare this cost to the cost of your eligible compute usage at the pay-as-you-go rates, and see how much you are saving with your savings plan.
Summary and feedback
In this article, we have covered the main aspects of Savings Plans for Compute Insights, a feature that can help you save money on your Azure compute costs by committing to a consistent amount of usage for a one-year or three-year term. We have explained how Savings Plans work, how they compare to reserved instances, how to use them at different levels, how to distribute the costs, and how to leverage Azure Advisor recommendations. We have also discussed some factors that you need to consider before purchasing a savings plan, such as your existing MACC discount, your usage patterns, your break-even point, and your utilization and performance monitoring.
We hope that this article has helped you understand and use Savings Plans for Compute Insights effectively, and that you can benefit from the flexibility and simplicity that they offer. We would love to hear your feedback on your experience with savings plans, and any suggestions for improvement or enhancement. You can contact us through the Azure feedback portal or leave a comment below. Thank you for reading, and happy saving!
References
[1] What is Azure savings plans for compute? – Microsoft Cost Management | Microsoft Learn
[2] Azure Savings Plan for Compute | Microsoft Azure
[3] Choose an Azure saving plan commitment amount – Microsoft Cost Management | Microsoft Learn
[4] Decide between a savings plan and a reservation – Microsoft Cost Management | Microsoft Learn
[5] How an Azure reservation discount is applied – Microsoft Cost Management | Microsoft Learn
[6] Track your Microsoft Azure Consumption Commitment (MACC) – Microsoft Cost Management | Microsoft Learn
[7] Start/Stop VMs v2 overview | Microsoft Learn
[8] Savings plan scopes – Microsoft Cost Management | Microsoft Learn
[9] How an Azure saving plan discount is applied – Microsoft Cost Management | Microsoft Learn
[10] IT chargeback and showback – Wikipedia
[11] Charge back Azure saving plan costs – Microsoft Cost Management | Microsoft Learn
[12] Group and allocate costs using tag inheritance – Microsoft Cost Management | Microsoft Learn
[13] View Azure savings plan utilization – Microsoft Cost Management | Microsoft Learn
[14] View Azure savings plan cost and usage – Microsoft Cost Management | Microsoft Learn
[15] Benefit Utilization Summaries – List By Billing Account Id – REST API (Azure Cost Management) | Microsoft Learn
[16] Introduction to Azure Advisor – Azure Advisor | Microsoft Learn
[17] Azure savings plan recommendations – Microsoft Cost Management | Microsoft Learn
[18] Azure saving plan cancellation policies – Microsoft Cost Management | Microsoft Learn
[19] Pricing Calculator | Microsoft Azure
[20] Metrics in Azure Monitor – Azure Monitor | Microsoft Learn
Microsoft Tech Community – Latest Blogs –Read More
How to find center and radius of an arc from binarized image
I have image of anulus, I need to find center and radius of inner and outer arcI have image of anulus, I need to find center and radius of inner and outer arc I have image of anulus, I need to find center and radius of inner and outer arc image processing, circle fitting, binary image processing MATLAB Answers — New Questions
generated rs code function result is not different with matlab simulink simulation
Hello,
I use the rs decoder of hdl coder. the simulation in matlab simulink is correct…
but when I load this code in fpga board and capture data by using the ILA, Its not same…
I think that when generated code is converted to verilog, difference is occured??
possible waring list..
optimization option
timing closure
tool version
1. optimization option : I set correct clock, fpga board, distributed pipeline … and so on.
-> I dont know that my setting value is correct????
2. timing satisfy, fpga clock : 16Mhz
3. matlab ver : 23a, vivado ver : 20.2
please give me check point….
thank you your corporation
Je Heo.Hello,
I use the rs decoder of hdl coder. the simulation in matlab simulink is correct…
but when I load this code in fpga board and capture data by using the ILA, Its not same…
I think that when generated code is converted to verilog, difference is occured??
possible waring list..
optimization option
timing closure
tool version
1. optimization option : I set correct clock, fpga board, distributed pipeline … and so on.
-> I dont know that my setting value is correct????
2. timing satisfy, fpga clock : 16Mhz
3. matlab ver : 23a, vivado ver : 20.2
please give me check point….
thank you your corporation
Je Heo. Hello,
I use the rs decoder of hdl coder. the simulation in matlab simulink is correct…
but when I load this code in fpga board and capture data by using the ILA, Its not same…
I think that when generated code is converted to verilog, difference is occured??
possible waring list..
optimization option
timing closure
tool version
1. optimization option : I set correct clock, fpga board, distributed pipeline … and so on.
-> I dont know that my setting value is correct????
2. timing satisfy, fpga clock : 16Mhz
3. matlab ver : 23a, vivado ver : 20.2
please give me check point….
thank you your corporation
Je Heo. hdl coder, rs decoder, fpga, generated hdl code, ila MATLAB Answers — New Questions
How do I plot a spectrogram of a real time plugin?
I managed to program a plugin that does a bit of reverb and a low pass filter. The plugin itself just shows me the spectrum of a signal during the time it is played but I need the entire spectrogram of that signal. Is there an option to plot the entire spectrogram with the audioTestBench function?
classdef FDNreverb2 < audioPlugin
properties
preDelayT = 0; % pre delay [ms]
reverbTime = 1.0; % reverb time [s]
roomSize = 5;
mix = 70; % mix of wet and dry signal [Percent], 100 % -> only wet
order = enumFDNorder.order8; % order of FDN, should be power of 2
in_coeff = 1/2; % coeff for in and output lines — just for now one value for all
out_coeff = 0.7;
end
properties (Access = private)
N = 8; % order of FDN
a = 1.1; % multiplying factor for delays
cSound = 343.2; % speed of sound
primeDelays = [2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 …
67 71 73 79 83 89 97 101 103 107 109 113 127 131];
% following values have to be set manually for Interface
maxPreDelay = 0.2; % max pre delay [s] (200ms)
maxRoomSize = 20.0; % max room size [m]
% following variables initialized in reset method
fs; % sample rate
A; % feedback matrix
b; % input gain coefficients
c; % output gain coefficients
f; % feedback lines after matrix
v; % signal before delay – v_i(n) = b_i * x(n) + f_i(n)
s; % output lines
d; % signal to be sent to matrix A
buffDelayLines; % buffer delay lines, initialized in reset method
m; % delay in samples of each delay line
g; % gain coefficients of delay lines
maxDelay; % maximum delay in delay lines
buffInput; % input buffer for pre delay
pBuffDelayLines; % pointer for delay lines buffer
pBuffInput; % pointer for input buffer
preDelayS; % preDelay in samples
alpha;
v_prev2;
v_prev1;
v_filt_prev1;
v_filt_prev2;
end
properties(Constant)
PluginInterface = audioPluginInterface( …
audioPluginParameter(‘preDelayT’, …
‘DisplayName’, ‘Pre Delay [ms]’, …
‘Mapping’, {‘int’, 0, 200}, …
‘Style’, ‘rotary’, …
‘Layout’, [1,1]), …
audioPluginParameter(‘roomSize’, …
‘DisplayName’, ‘Room Size [m]’, …
‘Mapping’, {‘lin’, 1.0, 20.0}, …
‘Style’, ‘rotary’, …
‘Layout’, [1,2]), …
audioPluginParameter(‘reverbTime’, …
‘DisplayName’, ‘Reverb Time [s]’, …
‘Mapping’, {‘lin’, 0.1, 5.0}, …
‘Style’, ‘rotary’, …
‘Layout’, [1,3]), …
audioPluginParameter(‘order’, …
‘DisplayName’, ‘Order of FDN’, …
‘Mapping’, {‘enum’, ‘8’, ’16’, ’32’}, …
‘Layout’, [3,2]), …
audioPluginParameter(‘in_coeff’, …
‘DisplayName’, ‘Input Gain’, …
‘Mapping’, {‘lin’, 0.0, 1.0}, …
‘Style’, ‘rotary’, …
‘Layout’, [3,3]), …
audioPluginParameter(‘out_coeff’, …
‘DisplayName’, ‘Output Gain’, …
‘Mapping’, {‘lin’, 0.0, 1.0}, …
‘Style’, ‘rotary’, …
‘Layout’, [3,4]), …
audioPluginParameter(‘mix’, …
‘DisplayName’, ‘Mix’, …
‘Mapping’, {‘int’, 0, 100}, …
‘Style’, ‘rotary’, …
‘Layout’, [3,1]), …
audioPluginGridLayout( …
‘RowHeight’, [100 100 100 100 100 100], …
‘ColumnWidth’,[100, 100 100 100 100 100], …
‘RowSpacing’, 10, …
‘ColumnSpacing’, 10, …
‘Padding’, [10 10 10 10]) …
);
end
methods
function plugin = FDNreverb
init(plugin)
end
function out = process(plugin, in)
out = zeros(size(in));
%Butterworth coefficients
[bx, ax] = butter(2, 3000/(plugin.fs/2)); % 2. Ordnung, Grenzfrequenz 1000 Hz
b0 = bx(1);
b1 = bx(2);
b2 = bx(3);
a1 = ax(2);
a2 = ax(3);
% rawVn(1) = b0*plugin.v(1);
% rawVn(2) = b0*plugin.v(2) + b1*plugin.v(1) – a1* rawVn(1);
% Define the cutoff frequency and calculate alpha
cutoffFreq = 1000; % Example cutoff frequency in Hz
plugin.alpha = (2 * pi * cutoffFreq) / (plugin.fs + 2 * pi * cutoffFreq);
% Initialize the previous output for the filter
prevY = zeros(plugin.N, 1);
for i = 1:size(in,1)
% Summieren der L/R – Kan�le
inL = in(i,1);
inR = in(i,2);
inSum = (inL + inR)/2;
plugin.buffInput(plugin.pBuffInput + 1) = inSum;
% loop over delay lines
for n=1:plugin.N
% d_n = gain * delayed v_n
for k=1:plugin.N
plugin.d(k) = plugin.g(k) * plugin.buffDelayLines(k, mod(plugin.pBuffDelayLines + plugin.m(k), plugin.maxDelay +1) + 1);
end
% f_n = A(n,:) * d’
plugin.f(n) = plugin.A(n,:) * plugin.d(:);
% v_n with pre delay
rawVn = plugin.b(n) * plugin.buffInput(mod(plugin.pBuffInput + plugin.preDelayS, (plugin.maxPreDelay * plugin.fs + 1)) + 1) + plugin.f(n);
% Filter anwenden
plugin.v(n) = b0 * rawVn + b1 * plugin.v_prev1(n) + b2 * plugin.v_prev2(n) …
– a1 * plugin.v_filt_prev1(n) – a2 * plugin.v_filt_prev2(n);
% Update der vorherigen Filterwerte
plugin.v_prev2(n) = plugin.v_prev1(n);
plugin.v_prev1(n) = rawVn;
plugin.v_filt_prev2(n) = plugin.v_filt_prev1(n);
plugin.v_filt_prev1(n) = plugin.v(n);
plugin.buffDelayLines(n, plugin.pBuffDelayLines + 1) = plugin.v(n);
% output lines
plugin.s(n) = plugin.c(n) * plugin.d(n);
out(i,:) = out(i,:) + real(plugin.s(n));
end
% Assign to output
out(i,1) = plugin.mix/100 * out(i,1) + (1.0 – plugin.mix/100) * in(i,1);
out(i,2) = plugin.mix/100 * out(i,2) + (1.0 – plugin.mix/100) * in(i,2);
calculatePointer(plugin);
end
end
function calculatePointer(plugin)
if (plugin.pBuffDelayLines==0)
plugin.pBuffDelayLines = plugin.maxDelay;
else
plugin.pBuffDelayLines = plugin.pBuffDelayLines – 1;
end
if (plugin.pBuffInput==0)
plugin.pBuffInput = plugin.maxPreDelay * plugin.fs;
else
plugin.pBuffInput = plugin.pBuffInput – 1;
end
end
function set.in_coeff(plugin, val)
plugin.in_coeff = val;
plugin.b = ones(plugin.N,1) * val;
end
function set.out_coeff(plugin, val)
plugin.out_coeff = val;
plugin.c = ones(plugin.N,1) * val;
end
function set.order(plugin, val)
plugin.order = val;
switch (plugin.order)
case enumFDNorder.order8
plugin.N = 8;
case enumFDNorder.order16
plugin.N = 16;
case enumFDNorder.order32
plugin.N = 32;
end
reset(plugin)
end
function set.reverbTime(plugin, val)
plugin.reverbTime = val;
calculateGainCoeffs(plugin, plugin.reverbTime)
calculateDelays(plugin)
%sprintf(‘Set Reverb Time: %f’, plugin.reverbTime)
%disp([‘Set Reverb Time: ‘, num2str(plugin.reverbTime), ‘ s.’]);
end
function set.preDelayT(plugin, val)
plugin.preDelayT = val;
calculatePreDelayS(plugin, plugin.preDelayT)
%disp([‘Set Predelay: ‘, int2str(plugin.preDelayT), ‘ ms.’]);
end
function set.mix(plugin, val)
plugin.mix = val;
%disp([‘Set Mix value: ‘, int2str(plugin.mix), ‘ %.’]);
end
function calculateMatrix(plugin)
plugin.A = generateFDNmatrix(plugin.N);
end
function calculateDelays(plugin)
% calculate sample delays dependent on room size (val) and
% sample rate (fs)
% m_1 = trace of sound / cSound * fs
M = ceil(0.15 * plugin.reverbTime * plugin.fs);
%disp([‘M = ‘, int2str(M)]);
plugin.m = zeros(plugin.N,1);
interval = M/(plugin.N*4);
%test = 0;
for i=1:plugin.N
tmp = interval/2 + (i-1) * interval;
e = floor(0.5 + log(tmp)/log(plugin.primeDelays(i)));
plugin.m(i) = plugin.primeDelays(i)^(e);
end
end
function calculateGainCoeffs(plugin, val)
for i=1:plugin.N
plugin.g(i) = 10^((-3) * (plugin.m(i)/plugin.fs) / val);
end
end
function calculatePreDelayS(plugin, val)
plugin.preDelayS = val * plugin.fs / 1000;
end
function init(plugin)
plugin.fs = getSampleRate(plugin);
% initialize buffDelayLines & pointer
%plugin.maxDelay = floor(plugin.maxRoomSize/plugin.cSound * plugin.fs * plugin.a^(plugin.N)); %probably higher than actual max delay as actual delays get rounded down
%plugin.maxDelay = ceil(0.15 * 5 * plugin.fs); % maximum possible delay for max reverb time = 5s
plugin.maxDelay = 131^2;
plugin.buffDelayLines = zeros(plugin.N, plugin.maxDelay + 1);
plugin.pBuffDelayLines = plugin.maxDelay;
%initialize filter elements
plugin.v_prev1 = zeros(plugin.N,1);
plugin.v_prev2 = zeros(plugin.N,1);
plugin.v_filt_prev2 = zeros(plugin.N,1);
plugin.v_filt_prev1 = zeros(plugin.N,1);
% initialize
plugin.A = zeros(plugin.N);
plugin.b = ones(plugin.N,1) * plugin.in_coeff; % input gain coefficients
plugin.c = ones(plugin.N,1) * plugin.out_coeff; % output gain coefficients
plugin.f = zeros(plugin.N,1); % feedback lines after matrix
plugin.v = zeros(plugin.N,1); % signal before delay – v_i(n) = b_i * x(n) + f_i(n)
plugin.s = zeros(plugin.N,1); % output lines
plugin.d = zeros(plugin.N,1); % signal to be sent fsto matrix A
plugin.m = zeros(plugin.N,1); % delay in samples of each delay line
plugin.g = zeros(plugin.N,1); % gain coefficients of delay lines
plugin.buffInput = zeros((plugin.maxPreDelay * plugin.fs) + 1, 1); % input buffer for pre delay, 0.2 = max pre delay of 200ms
plugin.preDelayS = 0; % pre delay in samples
plugin.pBuffInput = plugin.maxPreDelay * plugin.fs; % pointer for input buffer
% calculate sample delays of delay lines
calculateDelays(plugin)
% calculate gain coeffs of delay lines
calculateGainCoeffs(plugin, plugin.reverbTime)
% calculate FDN matrix based on set order
calculateMatrix(plugin)
end
function reset(plugin)
init(plugin)
end
function generateFDNmatrix(order)
% generates FDN matrix with evenly distributed eigenvalues at
% the unit circle
eig_nr = order/2;
FDNmatrix = zeros(order, order);
M = orth((rand(order,order)));
BC_n = zeros(order, order, eig_nr);
DtD_n = zeros(order, order, eig_nr);
k1 = 1;
for k=2:2:eig_nr*2
x = M(:,k-1);
y = M(:,k);
x = x / sqrt(2);
y = y / sqrt(2);
B = x * x.’;
C = y * y.’;
D = x * y.’;
BC_n(1:order,1:order,k1) = B + C;
DtD_n(1:order,1:order,k1) = D.’ – D;
w = pi * k / (eig_nr * 2 + 2);
temp = 2 * BC_n(:,:,k1) * cos(w) + 2 * DtD_n(:,:,k1) * sin(w);
FDNmatrix = FDNmatrix + temp;
k1 = k1 + 1;
end
end
end
endI managed to program a plugin that does a bit of reverb and a low pass filter. The plugin itself just shows me the spectrum of a signal during the time it is played but I need the entire spectrogram of that signal. Is there an option to plot the entire spectrogram with the audioTestBench function?
classdef FDNreverb2 < audioPlugin
properties
preDelayT = 0; % pre delay [ms]
reverbTime = 1.0; % reverb time [s]
roomSize = 5;
mix = 70; % mix of wet and dry signal [Percent], 100 % -> only wet
order = enumFDNorder.order8; % order of FDN, should be power of 2
in_coeff = 1/2; % coeff for in and output lines — just for now one value for all
out_coeff = 0.7;
end
properties (Access = private)
N = 8; % order of FDN
a = 1.1; % multiplying factor for delays
cSound = 343.2; % speed of sound
primeDelays = [2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 …
67 71 73 79 83 89 97 101 103 107 109 113 127 131];
% following values have to be set manually for Interface
maxPreDelay = 0.2; % max pre delay [s] (200ms)
maxRoomSize = 20.0; % max room size [m]
% following variables initialized in reset method
fs; % sample rate
A; % feedback matrix
b; % input gain coefficients
c; % output gain coefficients
f; % feedback lines after matrix
v; % signal before delay – v_i(n) = b_i * x(n) + f_i(n)
s; % output lines
d; % signal to be sent to matrix A
buffDelayLines; % buffer delay lines, initialized in reset method
m; % delay in samples of each delay line
g; % gain coefficients of delay lines
maxDelay; % maximum delay in delay lines
buffInput; % input buffer for pre delay
pBuffDelayLines; % pointer for delay lines buffer
pBuffInput; % pointer for input buffer
preDelayS; % preDelay in samples
alpha;
v_prev2;
v_prev1;
v_filt_prev1;
v_filt_prev2;
end
properties(Constant)
PluginInterface = audioPluginInterface( …
audioPluginParameter(‘preDelayT’, …
‘DisplayName’, ‘Pre Delay [ms]’, …
‘Mapping’, {‘int’, 0, 200}, …
‘Style’, ‘rotary’, …
‘Layout’, [1,1]), …
audioPluginParameter(‘roomSize’, …
‘DisplayName’, ‘Room Size [m]’, …
‘Mapping’, {‘lin’, 1.0, 20.0}, …
‘Style’, ‘rotary’, …
‘Layout’, [1,2]), …
audioPluginParameter(‘reverbTime’, …
‘DisplayName’, ‘Reverb Time [s]’, …
‘Mapping’, {‘lin’, 0.1, 5.0}, …
‘Style’, ‘rotary’, …
‘Layout’, [1,3]), …
audioPluginParameter(‘order’, …
‘DisplayName’, ‘Order of FDN’, …
‘Mapping’, {‘enum’, ‘8’, ’16’, ’32’}, …
‘Layout’, [3,2]), …
audioPluginParameter(‘in_coeff’, …
‘DisplayName’, ‘Input Gain’, …
‘Mapping’, {‘lin’, 0.0, 1.0}, …
‘Style’, ‘rotary’, …
‘Layout’, [3,3]), …
audioPluginParameter(‘out_coeff’, …
‘DisplayName’, ‘Output Gain’, …
‘Mapping’, {‘lin’, 0.0, 1.0}, …
‘Style’, ‘rotary’, …
‘Layout’, [3,4]), …
audioPluginParameter(‘mix’, …
‘DisplayName’, ‘Mix’, …
‘Mapping’, {‘int’, 0, 100}, …
‘Style’, ‘rotary’, …
‘Layout’, [3,1]), …
audioPluginGridLayout( …
‘RowHeight’, [100 100 100 100 100 100], …
‘ColumnWidth’,[100, 100 100 100 100 100], …
‘RowSpacing’, 10, …
‘ColumnSpacing’, 10, …
‘Padding’, [10 10 10 10]) …
);
end
methods
function plugin = FDNreverb
init(plugin)
end
function out = process(plugin, in)
out = zeros(size(in));
%Butterworth coefficients
[bx, ax] = butter(2, 3000/(plugin.fs/2)); % 2. Ordnung, Grenzfrequenz 1000 Hz
b0 = bx(1);
b1 = bx(2);
b2 = bx(3);
a1 = ax(2);
a2 = ax(3);
% rawVn(1) = b0*plugin.v(1);
% rawVn(2) = b0*plugin.v(2) + b1*plugin.v(1) – a1* rawVn(1);
% Define the cutoff frequency and calculate alpha
cutoffFreq = 1000; % Example cutoff frequency in Hz
plugin.alpha = (2 * pi * cutoffFreq) / (plugin.fs + 2 * pi * cutoffFreq);
% Initialize the previous output for the filter
prevY = zeros(plugin.N, 1);
for i = 1:size(in,1)
% Summieren der L/R – Kan�le
inL = in(i,1);
inR = in(i,2);
inSum = (inL + inR)/2;
plugin.buffInput(plugin.pBuffInput + 1) = inSum;
% loop over delay lines
for n=1:plugin.N
% d_n = gain * delayed v_n
for k=1:plugin.N
plugin.d(k) = plugin.g(k) * plugin.buffDelayLines(k, mod(plugin.pBuffDelayLines + plugin.m(k), plugin.maxDelay +1) + 1);
end
% f_n = A(n,:) * d’
plugin.f(n) = plugin.A(n,:) * plugin.d(:);
% v_n with pre delay
rawVn = plugin.b(n) * plugin.buffInput(mod(plugin.pBuffInput + plugin.preDelayS, (plugin.maxPreDelay * plugin.fs + 1)) + 1) + plugin.f(n);
% Filter anwenden
plugin.v(n) = b0 * rawVn + b1 * plugin.v_prev1(n) + b2 * plugin.v_prev2(n) …
– a1 * plugin.v_filt_prev1(n) – a2 * plugin.v_filt_prev2(n);
% Update der vorherigen Filterwerte
plugin.v_prev2(n) = plugin.v_prev1(n);
plugin.v_prev1(n) = rawVn;
plugin.v_filt_prev2(n) = plugin.v_filt_prev1(n);
plugin.v_filt_prev1(n) = plugin.v(n);
plugin.buffDelayLines(n, plugin.pBuffDelayLines + 1) = plugin.v(n);
% output lines
plugin.s(n) = plugin.c(n) * plugin.d(n);
out(i,:) = out(i,:) + real(plugin.s(n));
end
% Assign to output
out(i,1) = plugin.mix/100 * out(i,1) + (1.0 – plugin.mix/100) * in(i,1);
out(i,2) = plugin.mix/100 * out(i,2) + (1.0 – plugin.mix/100) * in(i,2);
calculatePointer(plugin);
end
end
function calculatePointer(plugin)
if (plugin.pBuffDelayLines==0)
plugin.pBuffDelayLines = plugin.maxDelay;
else
plugin.pBuffDelayLines = plugin.pBuffDelayLines – 1;
end
if (plugin.pBuffInput==0)
plugin.pBuffInput = plugin.maxPreDelay * plugin.fs;
else
plugin.pBuffInput = plugin.pBuffInput – 1;
end
end
function set.in_coeff(plugin, val)
plugin.in_coeff = val;
plugin.b = ones(plugin.N,1) * val;
end
function set.out_coeff(plugin, val)
plugin.out_coeff = val;
plugin.c = ones(plugin.N,1) * val;
end
function set.order(plugin, val)
plugin.order = val;
switch (plugin.order)
case enumFDNorder.order8
plugin.N = 8;
case enumFDNorder.order16
plugin.N = 16;
case enumFDNorder.order32
plugin.N = 32;
end
reset(plugin)
end
function set.reverbTime(plugin, val)
plugin.reverbTime = val;
calculateGainCoeffs(plugin, plugin.reverbTime)
calculateDelays(plugin)
%sprintf(‘Set Reverb Time: %f’, plugin.reverbTime)
%disp([‘Set Reverb Time: ‘, num2str(plugin.reverbTime), ‘ s.’]);
end
function set.preDelayT(plugin, val)
plugin.preDelayT = val;
calculatePreDelayS(plugin, plugin.preDelayT)
%disp([‘Set Predelay: ‘, int2str(plugin.preDelayT), ‘ ms.’]);
end
function set.mix(plugin, val)
plugin.mix = val;
%disp([‘Set Mix value: ‘, int2str(plugin.mix), ‘ %.’]);
end
function calculateMatrix(plugin)
plugin.A = generateFDNmatrix(plugin.N);
end
function calculateDelays(plugin)
% calculate sample delays dependent on room size (val) and
% sample rate (fs)
% m_1 = trace of sound / cSound * fs
M = ceil(0.15 * plugin.reverbTime * plugin.fs);
%disp([‘M = ‘, int2str(M)]);
plugin.m = zeros(plugin.N,1);
interval = M/(plugin.N*4);
%test = 0;
for i=1:plugin.N
tmp = interval/2 + (i-1) * interval;
e = floor(0.5 + log(tmp)/log(plugin.primeDelays(i)));
plugin.m(i) = plugin.primeDelays(i)^(e);
end
end
function calculateGainCoeffs(plugin, val)
for i=1:plugin.N
plugin.g(i) = 10^((-3) * (plugin.m(i)/plugin.fs) / val);
end
end
function calculatePreDelayS(plugin, val)
plugin.preDelayS = val * plugin.fs / 1000;
end
function init(plugin)
plugin.fs = getSampleRate(plugin);
% initialize buffDelayLines & pointer
%plugin.maxDelay = floor(plugin.maxRoomSize/plugin.cSound * plugin.fs * plugin.a^(plugin.N)); %probably higher than actual max delay as actual delays get rounded down
%plugin.maxDelay = ceil(0.15 * 5 * plugin.fs); % maximum possible delay for max reverb time = 5s
plugin.maxDelay = 131^2;
plugin.buffDelayLines = zeros(plugin.N, plugin.maxDelay + 1);
plugin.pBuffDelayLines = plugin.maxDelay;
%initialize filter elements
plugin.v_prev1 = zeros(plugin.N,1);
plugin.v_prev2 = zeros(plugin.N,1);
plugin.v_filt_prev2 = zeros(plugin.N,1);
plugin.v_filt_prev1 = zeros(plugin.N,1);
% initialize
plugin.A = zeros(plugin.N);
plugin.b = ones(plugin.N,1) * plugin.in_coeff; % input gain coefficients
plugin.c = ones(plugin.N,1) * plugin.out_coeff; % output gain coefficients
plugin.f = zeros(plugin.N,1); % feedback lines after matrix
plugin.v = zeros(plugin.N,1); % signal before delay – v_i(n) = b_i * x(n) + f_i(n)
plugin.s = zeros(plugin.N,1); % output lines
plugin.d = zeros(plugin.N,1); % signal to be sent fsto matrix A
plugin.m = zeros(plugin.N,1); % delay in samples of each delay line
plugin.g = zeros(plugin.N,1); % gain coefficients of delay lines
plugin.buffInput = zeros((plugin.maxPreDelay * plugin.fs) + 1, 1); % input buffer for pre delay, 0.2 = max pre delay of 200ms
plugin.preDelayS = 0; % pre delay in samples
plugin.pBuffInput = plugin.maxPreDelay * plugin.fs; % pointer for input buffer
% calculate sample delays of delay lines
calculateDelays(plugin)
% calculate gain coeffs of delay lines
calculateGainCoeffs(plugin, plugin.reverbTime)
% calculate FDN matrix based on set order
calculateMatrix(plugin)
end
function reset(plugin)
init(plugin)
end
function generateFDNmatrix(order)
% generates FDN matrix with evenly distributed eigenvalues at
% the unit circle
eig_nr = order/2;
FDNmatrix = zeros(order, order);
M = orth((rand(order,order)));
BC_n = zeros(order, order, eig_nr);
DtD_n = zeros(order, order, eig_nr);
k1 = 1;
for k=2:2:eig_nr*2
x = M(:,k-1);
y = M(:,k);
x = x / sqrt(2);
y = y / sqrt(2);
B = x * x.’;
C = y * y.’;
D = x * y.’;
BC_n(1:order,1:order,k1) = B + C;
DtD_n(1:order,1:order,k1) = D.’ – D;
w = pi * k / (eig_nr * 2 + 2);
temp = 2 * BC_n(:,:,k1) * cos(w) + 2 * DtD_n(:,:,k1) * sin(w);
FDNmatrix = FDNmatrix + temp;
k1 = k1 + 1;
end
end
end
end I managed to program a plugin that does a bit of reverb and a low pass filter. The plugin itself just shows me the spectrum of a signal during the time it is played but I need the entire spectrogram of that signal. Is there an option to plot the entire spectrogram with the audioTestBench function?
classdef FDNreverb2 < audioPlugin
properties
preDelayT = 0; % pre delay [ms]
reverbTime = 1.0; % reverb time [s]
roomSize = 5;
mix = 70; % mix of wet and dry signal [Percent], 100 % -> only wet
order = enumFDNorder.order8; % order of FDN, should be power of 2
in_coeff = 1/2; % coeff for in and output lines — just for now one value for all
out_coeff = 0.7;
end
properties (Access = private)
N = 8; % order of FDN
a = 1.1; % multiplying factor for delays
cSound = 343.2; % speed of sound
primeDelays = [2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 …
67 71 73 79 83 89 97 101 103 107 109 113 127 131];
% following values have to be set manually for Interface
maxPreDelay = 0.2; % max pre delay [s] (200ms)
maxRoomSize = 20.0; % max room size [m]
% following variables initialized in reset method
fs; % sample rate
A; % feedback matrix
b; % input gain coefficients
c; % output gain coefficients
f; % feedback lines after matrix
v; % signal before delay – v_i(n) = b_i * x(n) + f_i(n)
s; % output lines
d; % signal to be sent to matrix A
buffDelayLines; % buffer delay lines, initialized in reset method
m; % delay in samples of each delay line
g; % gain coefficients of delay lines
maxDelay; % maximum delay in delay lines
buffInput; % input buffer for pre delay
pBuffDelayLines; % pointer for delay lines buffer
pBuffInput; % pointer for input buffer
preDelayS; % preDelay in samples
alpha;
v_prev2;
v_prev1;
v_filt_prev1;
v_filt_prev2;
end
properties(Constant)
PluginInterface = audioPluginInterface( …
audioPluginParameter(‘preDelayT’, …
‘DisplayName’, ‘Pre Delay [ms]’, …
‘Mapping’, {‘int’, 0, 200}, …
‘Style’, ‘rotary’, …
‘Layout’, [1,1]), …
audioPluginParameter(‘roomSize’, …
‘DisplayName’, ‘Room Size [m]’, …
‘Mapping’, {‘lin’, 1.0, 20.0}, …
‘Style’, ‘rotary’, …
‘Layout’, [1,2]), …
audioPluginParameter(‘reverbTime’, …
‘DisplayName’, ‘Reverb Time [s]’, …
‘Mapping’, {‘lin’, 0.1, 5.0}, …
‘Style’, ‘rotary’, …
‘Layout’, [1,3]), …
audioPluginParameter(‘order’, …
‘DisplayName’, ‘Order of FDN’, …
‘Mapping’, {‘enum’, ‘8’, ’16’, ’32’}, …
‘Layout’, [3,2]), …
audioPluginParameter(‘in_coeff’, …
‘DisplayName’, ‘Input Gain’, …
‘Mapping’, {‘lin’, 0.0, 1.0}, …
‘Style’, ‘rotary’, …
‘Layout’, [3,3]), …
audioPluginParameter(‘out_coeff’, …
‘DisplayName’, ‘Output Gain’, …
‘Mapping’, {‘lin’, 0.0, 1.0}, …
‘Style’, ‘rotary’, …
‘Layout’, [3,4]), …
audioPluginParameter(‘mix’, …
‘DisplayName’, ‘Mix’, …
‘Mapping’, {‘int’, 0, 100}, …
‘Style’, ‘rotary’, …
‘Layout’, [3,1]), …
audioPluginGridLayout( …
‘RowHeight’, [100 100 100 100 100 100], …
‘ColumnWidth’,[100, 100 100 100 100 100], …
‘RowSpacing’, 10, …
‘ColumnSpacing’, 10, …
‘Padding’, [10 10 10 10]) …
);
end
methods
function plugin = FDNreverb
init(plugin)
end
function out = process(plugin, in)
out = zeros(size(in));
%Butterworth coefficients
[bx, ax] = butter(2, 3000/(plugin.fs/2)); % 2. Ordnung, Grenzfrequenz 1000 Hz
b0 = bx(1);
b1 = bx(2);
b2 = bx(3);
a1 = ax(2);
a2 = ax(3);
% rawVn(1) = b0*plugin.v(1);
% rawVn(2) = b0*plugin.v(2) + b1*plugin.v(1) – a1* rawVn(1);
% Define the cutoff frequency and calculate alpha
cutoffFreq = 1000; % Example cutoff frequency in Hz
plugin.alpha = (2 * pi * cutoffFreq) / (plugin.fs + 2 * pi * cutoffFreq);
% Initialize the previous output for the filter
prevY = zeros(plugin.N, 1);
for i = 1:size(in,1)
% Summieren der L/R – Kan�le
inL = in(i,1);
inR = in(i,2);
inSum = (inL + inR)/2;
plugin.buffInput(plugin.pBuffInput + 1) = inSum;
% loop over delay lines
for n=1:plugin.N
% d_n = gain * delayed v_n
for k=1:plugin.N
plugin.d(k) = plugin.g(k) * plugin.buffDelayLines(k, mod(plugin.pBuffDelayLines + plugin.m(k), plugin.maxDelay +1) + 1);
end
% f_n = A(n,:) * d’
plugin.f(n) = plugin.A(n,:) * plugin.d(:);
% v_n with pre delay
rawVn = plugin.b(n) * plugin.buffInput(mod(plugin.pBuffInput + plugin.preDelayS, (plugin.maxPreDelay * plugin.fs + 1)) + 1) + plugin.f(n);
% Filter anwenden
plugin.v(n) = b0 * rawVn + b1 * plugin.v_prev1(n) + b2 * plugin.v_prev2(n) …
– a1 * plugin.v_filt_prev1(n) – a2 * plugin.v_filt_prev2(n);
% Update der vorherigen Filterwerte
plugin.v_prev2(n) = plugin.v_prev1(n);
plugin.v_prev1(n) = rawVn;
plugin.v_filt_prev2(n) = plugin.v_filt_prev1(n);
plugin.v_filt_prev1(n) = plugin.v(n);
plugin.buffDelayLines(n, plugin.pBuffDelayLines + 1) = plugin.v(n);
% output lines
plugin.s(n) = plugin.c(n) * plugin.d(n);
out(i,:) = out(i,:) + real(plugin.s(n));
end
% Assign to output
out(i,1) = plugin.mix/100 * out(i,1) + (1.0 – plugin.mix/100) * in(i,1);
out(i,2) = plugin.mix/100 * out(i,2) + (1.0 – plugin.mix/100) * in(i,2);
calculatePointer(plugin);
end
end
function calculatePointer(plugin)
if (plugin.pBuffDelayLines==0)
plugin.pBuffDelayLines = plugin.maxDelay;
else
plugin.pBuffDelayLines = plugin.pBuffDelayLines – 1;
end
if (plugin.pBuffInput==0)
plugin.pBuffInput = plugin.maxPreDelay * plugin.fs;
else
plugin.pBuffInput = plugin.pBuffInput – 1;
end
end
function set.in_coeff(plugin, val)
plugin.in_coeff = val;
plugin.b = ones(plugin.N,1) * val;
end
function set.out_coeff(plugin, val)
plugin.out_coeff = val;
plugin.c = ones(plugin.N,1) * val;
end
function set.order(plugin, val)
plugin.order = val;
switch (plugin.order)
case enumFDNorder.order8
plugin.N = 8;
case enumFDNorder.order16
plugin.N = 16;
case enumFDNorder.order32
plugin.N = 32;
end
reset(plugin)
end
function set.reverbTime(plugin, val)
plugin.reverbTime = val;
calculateGainCoeffs(plugin, plugin.reverbTime)
calculateDelays(plugin)
%sprintf(‘Set Reverb Time: %f’, plugin.reverbTime)
%disp([‘Set Reverb Time: ‘, num2str(plugin.reverbTime), ‘ s.’]);
end
function set.preDelayT(plugin, val)
plugin.preDelayT = val;
calculatePreDelayS(plugin, plugin.preDelayT)
%disp([‘Set Predelay: ‘, int2str(plugin.preDelayT), ‘ ms.’]);
end
function set.mix(plugin, val)
plugin.mix = val;
%disp([‘Set Mix value: ‘, int2str(plugin.mix), ‘ %.’]);
end
function calculateMatrix(plugin)
plugin.A = generateFDNmatrix(plugin.N);
end
function calculateDelays(plugin)
% calculate sample delays dependent on room size (val) and
% sample rate (fs)
% m_1 = trace of sound / cSound * fs
M = ceil(0.15 * plugin.reverbTime * plugin.fs);
%disp([‘M = ‘, int2str(M)]);
plugin.m = zeros(plugin.N,1);
interval = M/(plugin.N*4);
%test = 0;
for i=1:plugin.N
tmp = interval/2 + (i-1) * interval;
e = floor(0.5 + log(tmp)/log(plugin.primeDelays(i)));
plugin.m(i) = plugin.primeDelays(i)^(e);
end
end
function calculateGainCoeffs(plugin, val)
for i=1:plugin.N
plugin.g(i) = 10^((-3) * (plugin.m(i)/plugin.fs) / val);
end
end
function calculatePreDelayS(plugin, val)
plugin.preDelayS = val * plugin.fs / 1000;
end
function init(plugin)
plugin.fs = getSampleRate(plugin);
% initialize buffDelayLines & pointer
%plugin.maxDelay = floor(plugin.maxRoomSize/plugin.cSound * plugin.fs * plugin.a^(plugin.N)); %probably higher than actual max delay as actual delays get rounded down
%plugin.maxDelay = ceil(0.15 * 5 * plugin.fs); % maximum possible delay for max reverb time = 5s
plugin.maxDelay = 131^2;
plugin.buffDelayLines = zeros(plugin.N, plugin.maxDelay + 1);
plugin.pBuffDelayLines = plugin.maxDelay;
%initialize filter elements
plugin.v_prev1 = zeros(plugin.N,1);
plugin.v_prev2 = zeros(plugin.N,1);
plugin.v_filt_prev2 = zeros(plugin.N,1);
plugin.v_filt_prev1 = zeros(plugin.N,1);
% initialize
plugin.A = zeros(plugin.N);
plugin.b = ones(plugin.N,1) * plugin.in_coeff; % input gain coefficients
plugin.c = ones(plugin.N,1) * plugin.out_coeff; % output gain coefficients
plugin.f = zeros(plugin.N,1); % feedback lines after matrix
plugin.v = zeros(plugin.N,1); % signal before delay – v_i(n) = b_i * x(n) + f_i(n)
plugin.s = zeros(plugin.N,1); % output lines
plugin.d = zeros(plugin.N,1); % signal to be sent fsto matrix A
plugin.m = zeros(plugin.N,1); % delay in samples of each delay line
plugin.g = zeros(plugin.N,1); % gain coefficients of delay lines
plugin.buffInput = zeros((plugin.maxPreDelay * plugin.fs) + 1, 1); % input buffer for pre delay, 0.2 = max pre delay of 200ms
plugin.preDelayS = 0; % pre delay in samples
plugin.pBuffInput = plugin.maxPreDelay * plugin.fs; % pointer for input buffer
% calculate sample delays of delay lines
calculateDelays(plugin)
% calculate gain coeffs of delay lines
calculateGainCoeffs(plugin, plugin.reverbTime)
% calculate FDN matrix based on set order
calculateMatrix(plugin)
end
function reset(plugin)
init(plugin)
end
function generateFDNmatrix(order)
% generates FDN matrix with evenly distributed eigenvalues at
% the unit circle
eig_nr = order/2;
FDNmatrix = zeros(order, order);
M = orth((rand(order,order)));
BC_n = zeros(order, order, eig_nr);
DtD_n = zeros(order, order, eig_nr);
k1 = 1;
for k=2:2:eig_nr*2
x = M(:,k-1);
y = M(:,k);
x = x / sqrt(2);
y = y / sqrt(2);
B = x * x.’;
C = y * y.’;
D = x * y.’;
BC_n(1:order,1:order,k1) = B + C;
DtD_n(1:order,1:order,k1) = D.’ – D;
w = pi * k / (eig_nr * 2 + 2);
temp = 2 * BC_n(:,:,k1) * cos(w) + 2 * DtD_n(:,:,k1) * sin(w);
FDNmatrix = FDNmatrix + temp;
k1 = k1 + 1;
end
end
end
end spectrogram, reverb, filter, audio toolbox MATLAB Answers — New Questions
Why my validation RMSE and loss increase after some epoch by my training data increase
Hello everyone
I am trying to predict traffic flow of future steps by previous collected data so I Use LSTM for it
but my validation loss and rmse increase and training loss and rmse decrease .because I am net to LSTM I don’t know which parameters I should check for improving model and predictions.
the picture of training progress is :
also I use different lags time for my predictions and here in my codes I have 4 step lag time
XTrain_ZaMir = (XTrain_ZaMir – mu_ZaMir)/sig_ZaMir;
YTrain_ZaMir = (YTrain_ZaMir – mu_ZaMir)/sig_ZaMir;
XTrain_ZaMir = XTrain_ZaMir(:,1:end-4);
YTrain_ZaMir = YTrain_ZaMir(:,5:end);
Test_ZaMir = [flowTe_ZaMir flowTeOther_ZaMir]’;
nt = floor(0.7*length(Test_ZaMir));
YTest_ZaMir = Test_ZaMir(1,1:end);
XTest_ZaMir = Test_ZaMir(1,1:end); %One input
% XTest_ZaMir = Test_ZaMir(:,1:end); % More than One input
XTest_ZaMir = (XTest_ZaMir – mu_ZaMir)/sig_ZaMir;
YTest_ZaMir = (YTest_ZaMir – mu_ZaMir)/sig_ZaMir;
XVal_ZaMir = XTest_ZaMir(:,1:nt-4);
YVal_ZaMir = YTest_ZaMir(:,5:nt);
XTest_ZaMir = XTest_ZaMir(:,nt+4:end-1);
YTest_ZaMir = YTest_ZaMir(:,nt+5:end);
%% Layers and Options
numResponses = 1 ;
featureDimension = 1;
numHiddenUnits =200 ;
layers = [ …
sequenceInputLayer(featureDimension)
lstmLayer(numHiddenUnits)
% dropoutLayer(0.002)
fullyConnectedLayer(numResponses)
regressionLayer
];
maxepochs = 250;
minibatchsize =128;
options = trainingOptions(‘adam’, … %%adam
‘MaxEpochs’,maxepochs, …
‘GradientThreshold’,1, …
‘InitialLearnRate’,0.005, …
‘ValidationData’,{XVal_ZaMir,YVal_ZaMir},…
‘ValidationFrequency’,20,…
‘Shuffle’,’every-epoch’,…
‘MiniBatchSize’,minibatchsize,…
‘LearnRateSchedule’,’piecewise’, …
‘LearnRateDropPeriod’,150, …
‘LearnRateDropFactor’,0.005, …
‘Verbose’,1, …
‘Plots’,’training-progress’);
%% Train the Network
[net,info] = trainNetwork(XTrain_ZaMir,YTrain_ZaMir,layers,options);
[net,YPred_ZaMir]= predictAndUpdateState(net,XTest_ZaMir);
numTimeStepsTest= (0.5*floor(length(XTest_ZaMir)));
for i = 2:numTimeStepsTest
[net,YPred_ZaMir(:,i)] = predictAndUpdateState(net,XTest_ZaMir(:,i-1),’ExecutionEnvironment’,’cpu’);
% net = resetState(net);
end
YTest_ZaMir = sig_ZaMir*YTest_ZaMir + mu_ZaMir;
YPred_ZaMir = sig_ZaMir*YPred_ZaMir + mu_ZaMir;Hello everyone
I am trying to predict traffic flow of future steps by previous collected data so I Use LSTM for it
but my validation loss and rmse increase and training loss and rmse decrease .because I am net to LSTM I don’t know which parameters I should check for improving model and predictions.
the picture of training progress is :
also I use different lags time for my predictions and here in my codes I have 4 step lag time
XTrain_ZaMir = (XTrain_ZaMir – mu_ZaMir)/sig_ZaMir;
YTrain_ZaMir = (YTrain_ZaMir – mu_ZaMir)/sig_ZaMir;
XTrain_ZaMir = XTrain_ZaMir(:,1:end-4);
YTrain_ZaMir = YTrain_ZaMir(:,5:end);
Test_ZaMir = [flowTe_ZaMir flowTeOther_ZaMir]’;
nt = floor(0.7*length(Test_ZaMir));
YTest_ZaMir = Test_ZaMir(1,1:end);
XTest_ZaMir = Test_ZaMir(1,1:end); %One input
% XTest_ZaMir = Test_ZaMir(:,1:end); % More than One input
XTest_ZaMir = (XTest_ZaMir – mu_ZaMir)/sig_ZaMir;
YTest_ZaMir = (YTest_ZaMir – mu_ZaMir)/sig_ZaMir;
XVal_ZaMir = XTest_ZaMir(:,1:nt-4);
YVal_ZaMir = YTest_ZaMir(:,5:nt);
XTest_ZaMir = XTest_ZaMir(:,nt+4:end-1);
YTest_ZaMir = YTest_ZaMir(:,nt+5:end);
%% Layers and Options
numResponses = 1 ;
featureDimension = 1;
numHiddenUnits =200 ;
layers = [ …
sequenceInputLayer(featureDimension)
lstmLayer(numHiddenUnits)
% dropoutLayer(0.002)
fullyConnectedLayer(numResponses)
regressionLayer
];
maxepochs = 250;
minibatchsize =128;
options = trainingOptions(‘adam’, … %%adam
‘MaxEpochs’,maxepochs, …
‘GradientThreshold’,1, …
‘InitialLearnRate’,0.005, …
‘ValidationData’,{XVal_ZaMir,YVal_ZaMir},…
‘ValidationFrequency’,20,…
‘Shuffle’,’every-epoch’,…
‘MiniBatchSize’,minibatchsize,…
‘LearnRateSchedule’,’piecewise’, …
‘LearnRateDropPeriod’,150, …
‘LearnRateDropFactor’,0.005, …
‘Verbose’,1, …
‘Plots’,’training-progress’);
%% Train the Network
[net,info] = trainNetwork(XTrain_ZaMir,YTrain_ZaMir,layers,options);
[net,YPred_ZaMir]= predictAndUpdateState(net,XTest_ZaMir);
numTimeStepsTest= (0.5*floor(length(XTest_ZaMir)));
for i = 2:numTimeStepsTest
[net,YPred_ZaMir(:,i)] = predictAndUpdateState(net,XTest_ZaMir(:,i-1),’ExecutionEnvironment’,’cpu’);
% net = resetState(net);
end
YTest_ZaMir = sig_ZaMir*YTest_ZaMir + mu_ZaMir;
YPred_ZaMir = sig_ZaMir*YPred_ZaMir + mu_ZaMir; Hello everyone
I am trying to predict traffic flow of future steps by previous collected data so I Use LSTM for it
but my validation loss and rmse increase and training loss and rmse decrease .because I am net to LSTM I don’t know which parameters I should check for improving model and predictions.
the picture of training progress is :
also I use different lags time for my predictions and here in my codes I have 4 step lag time
XTrain_ZaMir = (XTrain_ZaMir – mu_ZaMir)/sig_ZaMir;
YTrain_ZaMir = (YTrain_ZaMir – mu_ZaMir)/sig_ZaMir;
XTrain_ZaMir = XTrain_ZaMir(:,1:end-4);
YTrain_ZaMir = YTrain_ZaMir(:,5:end);
Test_ZaMir = [flowTe_ZaMir flowTeOther_ZaMir]’;
nt = floor(0.7*length(Test_ZaMir));
YTest_ZaMir = Test_ZaMir(1,1:end);
XTest_ZaMir = Test_ZaMir(1,1:end); %One input
% XTest_ZaMir = Test_ZaMir(:,1:end); % More than One input
XTest_ZaMir = (XTest_ZaMir – mu_ZaMir)/sig_ZaMir;
YTest_ZaMir = (YTest_ZaMir – mu_ZaMir)/sig_ZaMir;
XVal_ZaMir = XTest_ZaMir(:,1:nt-4);
YVal_ZaMir = YTest_ZaMir(:,5:nt);
XTest_ZaMir = XTest_ZaMir(:,nt+4:end-1);
YTest_ZaMir = YTest_ZaMir(:,nt+5:end);
%% Layers and Options
numResponses = 1 ;
featureDimension = 1;
numHiddenUnits =200 ;
layers = [ …
sequenceInputLayer(featureDimension)
lstmLayer(numHiddenUnits)
% dropoutLayer(0.002)
fullyConnectedLayer(numResponses)
regressionLayer
];
maxepochs = 250;
minibatchsize =128;
options = trainingOptions(‘adam’, … %%adam
‘MaxEpochs’,maxepochs, …
‘GradientThreshold’,1, …
‘InitialLearnRate’,0.005, …
‘ValidationData’,{XVal_ZaMir,YVal_ZaMir},…
‘ValidationFrequency’,20,…
‘Shuffle’,’every-epoch’,…
‘MiniBatchSize’,minibatchsize,…
‘LearnRateSchedule’,’piecewise’, …
‘LearnRateDropPeriod’,150, …
‘LearnRateDropFactor’,0.005, …
‘Verbose’,1, …
‘Plots’,’training-progress’);
%% Train the Network
[net,info] = trainNetwork(XTrain_ZaMir,YTrain_ZaMir,layers,options);
[net,YPred_ZaMir]= predictAndUpdateState(net,XTest_ZaMir);
numTimeStepsTest= (0.5*floor(length(XTest_ZaMir)));
for i = 2:numTimeStepsTest
[net,YPred_ZaMir(:,i)] = predictAndUpdateState(net,XTest_ZaMir(:,i-1),’ExecutionEnvironment’,’cpu’);
% net = resetState(net);
end
YTest_ZaMir = sig_ZaMir*YTest_ZaMir + mu_ZaMir;
YPred_ZaMir = sig_ZaMir*YPred_ZaMir + mu_ZaMir; predictions, lstm, validation, train MATLAB Answers — New Questions
How to do CAN Loopback test on jetson agx orin
Need to send a sample packet from can0 itself as loopback test or send from CAN0 to CAN1 in NVIDIA Jetson AGX Orin.Need to send a sample packet from can0 itself as loopback test or send from CAN0 to CAN1 in NVIDIA Jetson AGX Orin. Need to send a sample packet from can0 itself as loopback test or send from CAN0 to CAN1 in NVIDIA Jetson AGX Orin. can communication, nvidia jetson MATLAB Answers — New Questions