Tag Archives: matlab
how to plot function with 2 variables? using fsolve or bisection ?
Y=(M_1-M_2^2)*Y^3+ 2X^2 (chi(1-M_1^2)- M_1*M_2)(chi*Y^2(1-M_2^2)+(2M_1+M_2)^Y-2chi*X^2+1=0
where
M_1-M_2=0.1
chi=0.5
X>0Y=(M_1-M_2^2)*Y^3+ 2X^2 (chi(1-M_1^2)- M_1*M_2)(chi*Y^2(1-M_2^2)+(2M_1+M_2)^Y-2chi*X^2+1=0
where
M_1-M_2=0.1
chi=0.5
X>0 Y=(M_1-M_2^2)*Y^3+ 2X^2 (chi(1-M_1^2)- M_1*M_2)(chi*Y^2(1-M_2^2)+(2M_1+M_2)^Y-2chi*X^2+1=0
where
M_1-M_2=0.1
chi=0.5
X>0 select tags from the drop down list MATLAB Answers — New Questions
Face Difficulty when converting tensorflow model to Matlab
I have a part of tensorflow code that I need to translate to matlab, but fail to do that. I have checked deep learning toolbox and unable to resolve the issue. If someone can help me this question, it is very helpful.
My tensorflow code (Python) is the following:
def get_r(model,tw,xw,a_data_n,mean_a,mean_u,kP,dim1,dim2,w1,stdt,stdx):
% A tf.GradientTape is used to compute derivatives in TensorFlow
with tf.GradientTape(persistent=True) as tape: % This makes you record the gradients on the tape for the parameters defined
tape.watch(tw) % This is needed to ‘follow’ the time, for automatic differentiation with respect to time
tape.watch(xw) % This is needed to ‘follow’ the position, for automatic differentiation with respect to position
a,u,p = model.net_u(tw,xw)
Px = tape.gradient(p, xw)
At = tape.gradient(a, tw)
ux = tape.gradient(u, xw)
ut = tape.gradient(u, tw)
My Matlab Code is the following: (notice that model.net_u input cannot accept dlarray format, dlarrya has to be done after model.net_u fucntion)
function get_r(model, tw, xw, a_data_n, mean_a, mean_u, kP, dim1, dim2, w1, stdt, stdx)
% Compute derivatives using the MATLAB automatic differentiation functionality
% Run the model
[a, u, p] = model.net_u(tw, xw);
a = dlarray(a);
tw = dlarray(tw);
xw = dlarray(xw);
% Compute gradients by iterating over each element
At = dlgradient(a, tw);
Px = dlgradient(p, xw);
ux = dlgradient(u, xw);
ut = dlgradient(u, tw);
end
Also, my a, u, p variable all have the shape 39600 * 1
My error message is
Error using dlarray/dlgradient (line 105)
Value to differentiate is not traced. It must be a traced real dlarray scalar. Use dlgradient inside a function called by dlfeval to
trace the variables.
Error in get_r (line 12)
At = dlgradient(sum(a, ‘all’), tw);
Can anyone point out how can I improve the code by adding dlfeval and other codes as well.
Additionally, sometimes when I add dlfeval, it will create the following error. What does this error mean?
Error using deep.internal.dlfevalWithNestingCheck (line 14)
Nested dlfeval calls are not supported. To compute higher derivatives, set the ‘EnableHigherDerivatives’ option of the dlgradient
function to true.
Error in dlfeval (line 31)
[varargout{1:nargout}] = deep.internal.dlfevalWithNestingCheck(fun,varargin{:});
Thanks for all suggestions!I have a part of tensorflow code that I need to translate to matlab, but fail to do that. I have checked deep learning toolbox and unable to resolve the issue. If someone can help me this question, it is very helpful.
My tensorflow code (Python) is the following:
def get_r(model,tw,xw,a_data_n,mean_a,mean_u,kP,dim1,dim2,w1,stdt,stdx):
% A tf.GradientTape is used to compute derivatives in TensorFlow
with tf.GradientTape(persistent=True) as tape: % This makes you record the gradients on the tape for the parameters defined
tape.watch(tw) % This is needed to ‘follow’ the time, for automatic differentiation with respect to time
tape.watch(xw) % This is needed to ‘follow’ the position, for automatic differentiation with respect to position
a,u,p = model.net_u(tw,xw)
Px = tape.gradient(p, xw)
At = tape.gradient(a, tw)
ux = tape.gradient(u, xw)
ut = tape.gradient(u, tw)
My Matlab Code is the following: (notice that model.net_u input cannot accept dlarray format, dlarrya has to be done after model.net_u fucntion)
function get_r(model, tw, xw, a_data_n, mean_a, mean_u, kP, dim1, dim2, w1, stdt, stdx)
% Compute derivatives using the MATLAB automatic differentiation functionality
% Run the model
[a, u, p] = model.net_u(tw, xw);
a = dlarray(a);
tw = dlarray(tw);
xw = dlarray(xw);
% Compute gradients by iterating over each element
At = dlgradient(a, tw);
Px = dlgradient(p, xw);
ux = dlgradient(u, xw);
ut = dlgradient(u, tw);
end
Also, my a, u, p variable all have the shape 39600 * 1
My error message is
Error using dlarray/dlgradient (line 105)
Value to differentiate is not traced. It must be a traced real dlarray scalar. Use dlgradient inside a function called by dlfeval to
trace the variables.
Error in get_r (line 12)
At = dlgradient(sum(a, ‘all’), tw);
Can anyone point out how can I improve the code by adding dlfeval and other codes as well.
Additionally, sometimes when I add dlfeval, it will create the following error. What does this error mean?
Error using deep.internal.dlfevalWithNestingCheck (line 14)
Nested dlfeval calls are not supported. To compute higher derivatives, set the ‘EnableHigherDerivatives’ option of the dlgradient
function to true.
Error in dlfeval (line 31)
[varargout{1:nargout}] = deep.internal.dlfevalWithNestingCheck(fun,varargin{:});
Thanks for all suggestions! I have a part of tensorflow code that I need to translate to matlab, but fail to do that. I have checked deep learning toolbox and unable to resolve the issue. If someone can help me this question, it is very helpful.
My tensorflow code (Python) is the following:
def get_r(model,tw,xw,a_data_n,mean_a,mean_u,kP,dim1,dim2,w1,stdt,stdx):
% A tf.GradientTape is used to compute derivatives in TensorFlow
with tf.GradientTape(persistent=True) as tape: % This makes you record the gradients on the tape for the parameters defined
tape.watch(tw) % This is needed to ‘follow’ the time, for automatic differentiation with respect to time
tape.watch(xw) % This is needed to ‘follow’ the position, for automatic differentiation with respect to position
a,u,p = model.net_u(tw,xw)
Px = tape.gradient(p, xw)
At = tape.gradient(a, tw)
ux = tape.gradient(u, xw)
ut = tape.gradient(u, tw)
My Matlab Code is the following: (notice that model.net_u input cannot accept dlarray format, dlarrya has to be done after model.net_u fucntion)
function get_r(model, tw, xw, a_data_n, mean_a, mean_u, kP, dim1, dim2, w1, stdt, stdx)
% Compute derivatives using the MATLAB automatic differentiation functionality
% Run the model
[a, u, p] = model.net_u(tw, xw);
a = dlarray(a);
tw = dlarray(tw);
xw = dlarray(xw);
% Compute gradients by iterating over each element
At = dlgradient(a, tw);
Px = dlgradient(p, xw);
ux = dlgradient(u, xw);
ut = dlgradient(u, tw);
end
Also, my a, u, p variable all have the shape 39600 * 1
My error message is
Error using dlarray/dlgradient (line 105)
Value to differentiate is not traced. It must be a traced real dlarray scalar. Use dlgradient inside a function called by dlfeval to
trace the variables.
Error in get_r (line 12)
At = dlgradient(sum(a, ‘all’), tw);
Can anyone point out how can I improve the code by adding dlfeval and other codes as well.
Additionally, sometimes when I add dlfeval, it will create the following error. What does this error mean?
Error using deep.internal.dlfevalWithNestingCheck (line 14)
Nested dlfeval calls are not supported. To compute higher derivatives, set the ‘EnableHigherDerivatives’ option of the dlgradient
function to true.
Error in dlfeval (line 31)
[varargout{1:nargout}] = deep.internal.dlfevalWithNestingCheck(fun,varargin{:});
Thanks for all suggestions! deep learning MATLAB Answers — New Questions
Error message using SPM command spm_jobman
Hi everyone,
I try to run an adapted preprocessing script (got it from an collegue) for a fMRI analysis. Unfortunatelly, I’m stuck on the command spm_jobman and get the following error message:
Error using spm_jobman>fill_run_job
No executable modules, but still unresolved dependencies or incomplete module inputs.
Error in spm_jobman (line 247)
sts = fill_run_job(‘run’, cjob, varargin{3:end});
Error in s03_preprocessing_with_slice_timing_batch_NICCUE (line 79)
spm_jobman(‘run’, matlabbatch);
It would be really helpful, if somebody could tell me what the problem is.
Thank you very much!
FranziskaHi everyone,
I try to run an adapted preprocessing script (got it from an collegue) for a fMRI analysis. Unfortunatelly, I’m stuck on the command spm_jobman and get the following error message:
Error using spm_jobman>fill_run_job
No executable modules, but still unresolved dependencies or incomplete module inputs.
Error in spm_jobman (line 247)
sts = fill_run_job(‘run’, cjob, varargin{3:end});
Error in s03_preprocessing_with_slice_timing_batch_NICCUE (line 79)
spm_jobman(‘run’, matlabbatch);
It would be really helpful, if somebody could tell me what the problem is.
Thank you very much!
Franziska Hi everyone,
I try to run an adapted preprocessing script (got it from an collegue) for a fMRI analysis. Unfortunatelly, I’m stuck on the command spm_jobman and get the following error message:
Error using spm_jobman>fill_run_job
No executable modules, but still unresolved dependencies or incomplete module inputs.
Error in spm_jobman (line 247)
sts = fill_run_job(‘run’, cjob, varargin{3:end});
Error in s03_preprocessing_with_slice_timing_batch_NICCUE (line 79)
spm_jobman(‘run’, matlabbatch);
It would be really helpful, if somebody could tell me what the problem is.
Thank you very much!
Franziska spm spm_jobman fmri MATLAB Answers — New Questions
how to modify this code to estimate LCOE using the parameters for offshore wind?
CAPEX ESTIMATION (KUSD)
% CAPEX OF WIND TURBINE
USD = 1000; Pwt = 400; dp = 30; Nwt = 50; Lcc = 10620; Acc = 6691; Loffs = 10; Lonsh = 2;
CAPwt = 1497.9 * Pwt^0.87; T = 20; WACC = 0.10;
% CAPEX OF BUILDING
CAbui = (0.9181 * dp^2 – 31.43 * dp + 747.4) * 1.09 * Pwt;
% CAPEX OF PROJECT MANAGEMENT
CApm = 130.82 * Pwt;
% CAPEX OF SUPERVISORY CONTROL AND DATA ACQUISITION
CAscda = 555.1 * Nwt;
% CAPEX OF ACQUISITION OF WIND POWER CONNECTION CABLES
CAawpc = ((4.26 * 10^-4 * Acc) + (2.324 * 10^-1)) * 1.09 * Lcc;
% INSTALLATION OF WIND POWER CONNECTION CABLES
CAiwpc = ((-2.2684 * 10^-3 * Nwt) + (3.8018 * 10^-1)) * 1.09 * Lcc;
% ACQUISITION OF OFFSHORE TRANSMISSION CABLES
CAaotc = ((3.3565 * 10^-3 * Pwt) + (8.3872 * 10^-2)) * Loffs * 1.09;
% CAPEX OF INSTALLATION OF OFFSHORE TRANSMISSION CABLES
CAiotc = ((-6.318 * 10^-4 * Pwt) + (3.8125 * 10^-1)) * 1.09 * Loffs;
% CAPEX OF ACQUISITION OF ONSHORE TRANSMISSION CABLES
CAaontc = ((-3.3565 * 10^-3 * Pwt) + (8.3872 * 10^-2)) * 0.27 * Lonsh;
% CAPEX OF INSTALLATION OF ONSHORE TRANSMISSION CABLES
CAiontc = 0.578 * Lonsh;
% Total CAPEX
CApexT = (CAPwt + CAbui + CApm + CAscda + CAawpc + CAiwpc + CAaotc + CAiotc + CAaontc + CAiontc);
CAXNEW = CApexT – 0.2 * CApexT;
% OPEX
Dexex = 0.003 * CApexT;
% TOTAL CAPEX IN NAIRA
CApexTN = CApexT * USD * 10^3;
% TOTAL OPEX AND DEXEX IN NAIRA
DexexN = Dexex * USD * 10^3;
Opex = 0.035 * CApexT;
OpexN = Opex * USD * 10^3;
n = 20; Rb = 10; AEPv = 28298304; Civ = 668860000; Cdex = 2006600; Cpex = 23410000;
% Calculate LCOE
AEP = 28298304;
lcoe = calculate_lcoe(CAXNEW, Opex, WACC, AEP, T);
% Display the LCOE
disp([‘The LCOE is ‘, num2str(lcoe), ‘ currency units per kWh’]);
% Function definition
function lcoe = calculate_lcoe(CAXNEW, Opex, WACC, AEP, T)
% Calculate the numerator of the LCOE formula
numerator = CAXNEW;
for t = 1:T
numerator = numerator + Opex / (1 + WACC)^t;
end
% Calculate the denominator of the LCOE formula
denominator = 0;
for t = 1:T
denominator = denominator + AEP / (1 + WACC)^t;
end
% Calculate the LCOE
lcoe = numerator / denominator;
endCAPEX ESTIMATION (KUSD)
% CAPEX OF WIND TURBINE
USD = 1000; Pwt = 400; dp = 30; Nwt = 50; Lcc = 10620; Acc = 6691; Loffs = 10; Lonsh = 2;
CAPwt = 1497.9 * Pwt^0.87; T = 20; WACC = 0.10;
% CAPEX OF BUILDING
CAbui = (0.9181 * dp^2 – 31.43 * dp + 747.4) * 1.09 * Pwt;
% CAPEX OF PROJECT MANAGEMENT
CApm = 130.82 * Pwt;
% CAPEX OF SUPERVISORY CONTROL AND DATA ACQUISITION
CAscda = 555.1 * Nwt;
% CAPEX OF ACQUISITION OF WIND POWER CONNECTION CABLES
CAawpc = ((4.26 * 10^-4 * Acc) + (2.324 * 10^-1)) * 1.09 * Lcc;
% INSTALLATION OF WIND POWER CONNECTION CABLES
CAiwpc = ((-2.2684 * 10^-3 * Nwt) + (3.8018 * 10^-1)) * 1.09 * Lcc;
% ACQUISITION OF OFFSHORE TRANSMISSION CABLES
CAaotc = ((3.3565 * 10^-3 * Pwt) + (8.3872 * 10^-2)) * Loffs * 1.09;
% CAPEX OF INSTALLATION OF OFFSHORE TRANSMISSION CABLES
CAiotc = ((-6.318 * 10^-4 * Pwt) + (3.8125 * 10^-1)) * 1.09 * Loffs;
% CAPEX OF ACQUISITION OF ONSHORE TRANSMISSION CABLES
CAaontc = ((-3.3565 * 10^-3 * Pwt) + (8.3872 * 10^-2)) * 0.27 * Lonsh;
% CAPEX OF INSTALLATION OF ONSHORE TRANSMISSION CABLES
CAiontc = 0.578 * Lonsh;
% Total CAPEX
CApexT = (CAPwt + CAbui + CApm + CAscda + CAawpc + CAiwpc + CAaotc + CAiotc + CAaontc + CAiontc);
CAXNEW = CApexT – 0.2 * CApexT;
% OPEX
Dexex = 0.003 * CApexT;
% TOTAL CAPEX IN NAIRA
CApexTN = CApexT * USD * 10^3;
% TOTAL OPEX AND DEXEX IN NAIRA
DexexN = Dexex * USD * 10^3;
Opex = 0.035 * CApexT;
OpexN = Opex * USD * 10^3;
n = 20; Rb = 10; AEPv = 28298304; Civ = 668860000; Cdex = 2006600; Cpex = 23410000;
% Calculate LCOE
AEP = 28298304;
lcoe = calculate_lcoe(CAXNEW, Opex, WACC, AEP, T);
% Display the LCOE
disp([‘The LCOE is ‘, num2str(lcoe), ‘ currency units per kWh’]);
% Function definition
function lcoe = calculate_lcoe(CAXNEW, Opex, WACC, AEP, T)
% Calculate the numerator of the LCOE formula
numerator = CAXNEW;
for t = 1:T
numerator = numerator + Opex / (1 + WACC)^t;
end
% Calculate the denominator of the LCOE formula
denominator = 0;
for t = 1:T
denominator = denominator + AEP / (1 + WACC)^t;
end
% Calculate the LCOE
lcoe = numerator / denominator;
end CAPEX ESTIMATION (KUSD)
% CAPEX OF WIND TURBINE
USD = 1000; Pwt = 400; dp = 30; Nwt = 50; Lcc = 10620; Acc = 6691; Loffs = 10; Lonsh = 2;
CAPwt = 1497.9 * Pwt^0.87; T = 20; WACC = 0.10;
% CAPEX OF BUILDING
CAbui = (0.9181 * dp^2 – 31.43 * dp + 747.4) * 1.09 * Pwt;
% CAPEX OF PROJECT MANAGEMENT
CApm = 130.82 * Pwt;
% CAPEX OF SUPERVISORY CONTROL AND DATA ACQUISITION
CAscda = 555.1 * Nwt;
% CAPEX OF ACQUISITION OF WIND POWER CONNECTION CABLES
CAawpc = ((4.26 * 10^-4 * Acc) + (2.324 * 10^-1)) * 1.09 * Lcc;
% INSTALLATION OF WIND POWER CONNECTION CABLES
CAiwpc = ((-2.2684 * 10^-3 * Nwt) + (3.8018 * 10^-1)) * 1.09 * Lcc;
% ACQUISITION OF OFFSHORE TRANSMISSION CABLES
CAaotc = ((3.3565 * 10^-3 * Pwt) + (8.3872 * 10^-2)) * Loffs * 1.09;
% CAPEX OF INSTALLATION OF OFFSHORE TRANSMISSION CABLES
CAiotc = ((-6.318 * 10^-4 * Pwt) + (3.8125 * 10^-1)) * 1.09 * Loffs;
% CAPEX OF ACQUISITION OF ONSHORE TRANSMISSION CABLES
CAaontc = ((-3.3565 * 10^-3 * Pwt) + (8.3872 * 10^-2)) * 0.27 * Lonsh;
% CAPEX OF INSTALLATION OF ONSHORE TRANSMISSION CABLES
CAiontc = 0.578 * Lonsh;
% Total CAPEX
CApexT = (CAPwt + CAbui + CApm + CAscda + CAawpc + CAiwpc + CAaotc + CAiotc + CAaontc + CAiontc);
CAXNEW = CApexT – 0.2 * CApexT;
% OPEX
Dexex = 0.003 * CApexT;
% TOTAL CAPEX IN NAIRA
CApexTN = CApexT * USD * 10^3;
% TOTAL OPEX AND DEXEX IN NAIRA
DexexN = Dexex * USD * 10^3;
Opex = 0.035 * CApexT;
OpexN = Opex * USD * 10^3;
n = 20; Rb = 10; AEPv = 28298304; Civ = 668860000; Cdex = 2006600; Cpex = 23410000;
% Calculate LCOE
AEP = 28298304;
lcoe = calculate_lcoe(CAXNEW, Opex, WACC, AEP, T);
% Display the LCOE
disp([‘The LCOE is ‘, num2str(lcoe), ‘ currency units per kWh’]);
% Function definition
function lcoe = calculate_lcoe(CAXNEW, Opex, WACC, AEP, T)
% Calculate the numerator of the LCOE formula
numerator = CAXNEW;
for t = 1:T
numerator = numerator + Opex / (1 + WACC)^t;
end
% Calculate the denominator of the LCOE formula
denominator = 0;
for t = 1:T
denominator = denominator + AEP / (1 + WACC)^t;
end
% Calculate the LCOE
lcoe = numerator / denominator;
end my research MATLAB Answers — New Questions
choose B or C or D if A does not exist – how to write this?
Hi all,
I have the following:
switch joint
case ‘Knee’
prox = ‘HipJC’;
dist = ‘LEPI’;
wand = ‘THPA’ ;
end
side = {‘R’,’L’};
for i = 1:length(side)
wandMk = data.([side{i},wand]).line;
end
I got the following error: Unrecognized field name "LTHPA", which is because ‘LTHPA’ does not exist in my structure.
I could use ‘THPP’ or ‘THDA’ or ‘THDP’ instead of ‘THPA’, because I know these exist. Hence, how could I rewrite the above for this to run?
For example:
if ‘THPA’ does not exist then
wand = ‘THDA’ or ‘THDA’ or ‘THDP’
Thanks!Hi all,
I have the following:
switch joint
case ‘Knee’
prox = ‘HipJC’;
dist = ‘LEPI’;
wand = ‘THPA’ ;
end
side = {‘R’,’L’};
for i = 1:length(side)
wandMk = data.([side{i},wand]).line;
end
I got the following error: Unrecognized field name "LTHPA", which is because ‘LTHPA’ does not exist in my structure.
I could use ‘THPP’ or ‘THDA’ or ‘THDP’ instead of ‘THPA’, because I know these exist. Hence, how could I rewrite the above for this to run?
For example:
if ‘THPA’ does not exist then
wand = ‘THDA’ or ‘THDA’ or ‘THDP’
Thanks! Hi all,
I have the following:
switch joint
case ‘Knee’
prox = ‘HipJC’;
dist = ‘LEPI’;
wand = ‘THPA’ ;
end
side = {‘R’,’L’};
for i = 1:length(side)
wandMk = data.([side{i},wand]).line;
end
I got the following error: Unrecognized field name "LTHPA", which is because ‘LTHPA’ does not exist in my structure.
I could use ‘THPP’ or ‘THDA’ or ‘THDP’ instead of ‘THPA’, because I know these exist. Hence, how could I rewrite the above for this to run?
For example:
if ‘THPA’ does not exist then
wand = ‘THDA’ or ‘THDA’ or ‘THDP’
Thanks! for loop, indexing, if statement MATLAB Answers — New Questions
how to get a good estimate of the positive parameters that will give a good fit of the curves to real data?
clear
close all
clc
% Données spécifiques
specific_data = [
2009 2 8;
2010 10 22;
2011 30 45;
2012 111 75;
2013 125 96;
2014 255 192;
2015 379 227;
2016 384 238
2017 360 279;
2018 399 229;
2019 235 128
];
% Utilisez les données spécifiques
tdata = specific_data(:, 1);
Hdata = specific_data(:, 2);
HSdata = specific_data(:, 3);
tforward = 2009:1:2019;
%tmeasure = [ 1:100:1001]’;
% initial values
gamma = 1.5;
phi_S = 0.0006; % transmission prob
phi_H = 0.000051; % trans proba
c1=3;
c2=1.5;
theta1 = 100; % djustment parameters for syph
theta2 = 4; %djustment parameters for hi
alpha = 0.6; % progression rate
beta = 0.2; %Complications rate
rho1 = 0.4; % adjustment parameters
rho2 = 1.5; % adjustment parameters
rho3 = 1.5; % adjustment parameters
k0 = [phi_S phi_H c1 c2 theta1 theta2 alpha beta rho1 rho2 rho3 ];
% solve equ with initial value of parameters
[t, Y] = ode23s(@(t, y)modelhs(t, y, k0), tforward, [ 5000.0 20.0 2.0 0.0 6.0 2.0 0.0 ]);
yintM = Y(:,1);
yintS = Y(:,2);
yintH1 = Y(:,3);
yintH2 = Y(:,4);
yintH1S=Y(:,5);
yintH2S=Y(:,6);
Hh=phi_H * ( yintH1 + c1 * yintH1S ).*yintM + rho1 * gamma * yintH1S + alpha* yintH2; % new cases from monoH
HShs=theta1*phi_S * ( yintS + c2 * yintH1S ).*yintH1 + theta2*phi_H * ( yintH1 + c1 * yintH1S ).*yintS+ rho2*alpha*yintH1S; %new case of co h-s
%H2q = Y(:,4);% assignts the y-coordinates of .
% Plotting specific data and solutions
% Display the results
figure(1)
%subplot(1,2,1);
plot(tdata, Hdata, ‘r*’);
hold on
plot(tdata, Hh, ‘b-‘);
xlabel(‘time in days’);
ylabel(‘Number of monhiv cases’);
axis([2009 2019 0 500]);
figure(2)
%subplot(1,2,1);
plot(tdata, HSdata, ‘r*’);
hold on
plot(tdata, HShs, ‘b-‘);
xlabel(‘time in days’);
ylabel(‘Number of Coinfection cases’);
axis([2009 2019 0 500]);
% Minimization routine using Nelder & Mead Simplex algorithm (a derivative-free method)
% Assigns the new values of parameters to k and the error to fval
% Minimization routine using Nelder & Mead Simplex algorithm (a derivative-free method)
% Assigns the new values of parameters to k and the error to fval
[k,fval] = fminsearch(@moderHS,k0)
%print final values of alpha and beta
disp(k);
%Draw the data with the final ODE
[T, Y] = ode45(@(t,y)(modelhs(t,y,k)),tforward,[ 5000.0 20.0 2.0 0.0 6.0 2.0 0.0 ]);
yintM = Y(:,1);
yintS = Y(:,2);
yintH1 = Y(:,3);
yintH2 = Y(:,4);
yintH1S=Y(:,5);
yintH2S=Y(:,6);
Hh=phi_H * ( yintH1 + c1 * yintH1S ).*yintM + rho1 * gamma * yintH1S + alpha* yintH2; % new cases from mono-HIV
HShs=theta1*phi_S * ( yintS + c2 * yintH1S ).*yintH1 + theta2*phi_H * ( yintH1 + c1 * yintH1S ).*yintS+ rho2*alpha*yintH1S; %new case of coinfection hiv+syphilis
%H2q = Y(:,4);% assignts the y-coordinates of …
residuals = (Hdata+HSdata – Hh-HShs)./2;
%subplot(1,2,2);
figure(3)
plot(tdata,Hdata,’r*’);
hold on
plot(tdata,Hh,’b-‘);
xlabel(‘Time in days’);
ylabel(‘Number of mono-HIV cases’);
axis([2009 2019 0 1000]);
legend(‘Data’, ‘Model estimation’);
figure(4)
plot(tdata,HSdata,’r*’);
hold on
plot(tdata,HShs,’b-‘);
xlabel(‘Time in days’);
ylabel(‘Number of Coinfection cases’);
axis([2009 2019 0 1000]);
legend(‘Data’, ‘Model estimation’);
function dy=modelhs(~,y,k)
delta = 0.01; % Taux de mortalité
delta_S = 0.05; % Taux de mort de Syphilis.
delta_H = 0.4;
Lambda =4.04 *100;
gamma=1.5;
phi_S =k(1);
phi_H =k(2);
c1 = k(3);
c2=k(4) ;
theta1 =k(5) ;
theta2 = k(6);
alpha = k(7);
beta = k(8);
rho1 = k(9);
rho2= k(10);
rho3=k(11);
dy = zeros(7,1);
%lambda_s=phi_S * ( y(2) + c2 * y(5))
%lambda_H= phi_H * ( y(3) + c1 * y(5) )
dy(1) = Lambda + gamma * y(2) – (phi_S * ( y(2) + c2 * y(5)) + phi_H * (y(3) + c1 * y(5)) + delta ) * y(1) ;%M
dy(2)= phi_S * ( y(2) + c2 * y(5) ) * y(1) – ( gamma + theta2 * phi_H * ( y(3) + c1 * y(5) ) + delta_S ) * y(2) ;%S
dy(3) = phi_H * ( y(3) + c1 * y(5) ) * y(1) + rho1 * gamma * y(5) – (theta1 * phi_S * ( y(2) + c2 * y(5)) + delta + delta_H + alpha) * y(3) ;%H1
dy(4) = alpha * y(3) – (beta + delta + delta_H) * y(4) ;%H2
dy(5) = theta2 * phi_H * ( y(3) + c1 * y(5) ) * y(2) + ( theta1 * phi_S * ( y(2) + c2 * y(5) ) ) * y(3) – ( rho1 * gamma + rho2 * alpha + delta_H + delta_S + delta ) * y(5) ;%H1S
dy(6)= rho2 * alpha * y(5) – ( rho3 * beta + delta_S + delta_H + delta ) * y(6) ;%H2S
dy(7)= beta * y(4) + rho3 * beta * y(6) – ( delta + delta_H ) * y(7) ;%C
end
function error_in_data = moderHS(k)
% Données spécifiques
specific_data = [
2009 2 8;
2010 10 22;
2011 30 45;
2012 111 75;
2013 125 96;
2014 255 192;
2015 379 227;
2016 384 238
2017 360 279;
2018 399 229;
2019 235 128
];
gamma = 1.5;
phi_S =k(1);
phi_H =k(2);
c1 = k(3);
c2=k(4) ;
theta1 =k(5) ;
theta2 = k(6);
alpha = k(7);
beta = k(8);
rho1 = k(9);
rho2= k(10);
rho3=k(11);
% Utilisez les données spécifiques
tdata = specific_data(:, 1);
Hdata = specific_data(:, 2);
HSdata = specific_data(:, 3);
tforward = 2009:1:2019;
[T, Y] = ode23s(@(t,y)(modelhs(t,y,k)),tforward,[ 5000.0 20.0 2.0 0.0 6.0 2.0 0.0 ]);
M = Y(:,1);
S = Y(:,2);
H1 = Y(:,3);
H2 = Y(:,4);
H1S=Y(:,5);
H2S=Y(:,6);
H=phi_H * ( H1 + c1 * H1S ).*M + rho1 * gamma*H1S + alpha* H2; % new cases from mono-HIV
HS=theta1*phi_S * ( S + c2 * H1S ).*H1 + theta2*phi_H * ( H1 + c1 * H1S ).*S+ rho2*alpha*H1S; %new case of coinfection hiv+syphilis
%H2q = Y(:,4);% assignts the y-coordinates of …
%the solution at
D=mean(Hdata).^2;
D1=mean(HSdata).^2;
A=(H – Hdata).^2;
B=(HS – HSdata).^2;
error_in_data =sum(A)./(11*D)+ sum(B)./(11*D1);
%%
endclear
close all
clc
% Données spécifiques
specific_data = [
2009 2 8;
2010 10 22;
2011 30 45;
2012 111 75;
2013 125 96;
2014 255 192;
2015 379 227;
2016 384 238
2017 360 279;
2018 399 229;
2019 235 128
];
% Utilisez les données spécifiques
tdata = specific_data(:, 1);
Hdata = specific_data(:, 2);
HSdata = specific_data(:, 3);
tforward = 2009:1:2019;
%tmeasure = [ 1:100:1001]’;
% initial values
gamma = 1.5;
phi_S = 0.0006; % transmission prob
phi_H = 0.000051; % trans proba
c1=3;
c2=1.5;
theta1 = 100; % djustment parameters for syph
theta2 = 4; %djustment parameters for hi
alpha = 0.6; % progression rate
beta = 0.2; %Complications rate
rho1 = 0.4; % adjustment parameters
rho2 = 1.5; % adjustment parameters
rho3 = 1.5; % adjustment parameters
k0 = [phi_S phi_H c1 c2 theta1 theta2 alpha beta rho1 rho2 rho3 ];
% solve equ with initial value of parameters
[t, Y] = ode23s(@(t, y)modelhs(t, y, k0), tforward, [ 5000.0 20.0 2.0 0.0 6.0 2.0 0.0 ]);
yintM = Y(:,1);
yintS = Y(:,2);
yintH1 = Y(:,3);
yintH2 = Y(:,4);
yintH1S=Y(:,5);
yintH2S=Y(:,6);
Hh=phi_H * ( yintH1 + c1 * yintH1S ).*yintM + rho1 * gamma * yintH1S + alpha* yintH2; % new cases from monoH
HShs=theta1*phi_S * ( yintS + c2 * yintH1S ).*yintH1 + theta2*phi_H * ( yintH1 + c1 * yintH1S ).*yintS+ rho2*alpha*yintH1S; %new case of co h-s
%H2q = Y(:,4);% assignts the y-coordinates of .
% Plotting specific data and solutions
% Display the results
figure(1)
%subplot(1,2,1);
plot(tdata, Hdata, ‘r*’);
hold on
plot(tdata, Hh, ‘b-‘);
xlabel(‘time in days’);
ylabel(‘Number of monhiv cases’);
axis([2009 2019 0 500]);
figure(2)
%subplot(1,2,1);
plot(tdata, HSdata, ‘r*’);
hold on
plot(tdata, HShs, ‘b-‘);
xlabel(‘time in days’);
ylabel(‘Number of Coinfection cases’);
axis([2009 2019 0 500]);
% Minimization routine using Nelder & Mead Simplex algorithm (a derivative-free method)
% Assigns the new values of parameters to k and the error to fval
% Minimization routine using Nelder & Mead Simplex algorithm (a derivative-free method)
% Assigns the new values of parameters to k and the error to fval
[k,fval] = fminsearch(@moderHS,k0)
%print final values of alpha and beta
disp(k);
%Draw the data with the final ODE
[T, Y] = ode45(@(t,y)(modelhs(t,y,k)),tforward,[ 5000.0 20.0 2.0 0.0 6.0 2.0 0.0 ]);
yintM = Y(:,1);
yintS = Y(:,2);
yintH1 = Y(:,3);
yintH2 = Y(:,4);
yintH1S=Y(:,5);
yintH2S=Y(:,6);
Hh=phi_H * ( yintH1 + c1 * yintH1S ).*yintM + rho1 * gamma * yintH1S + alpha* yintH2; % new cases from mono-HIV
HShs=theta1*phi_S * ( yintS + c2 * yintH1S ).*yintH1 + theta2*phi_H * ( yintH1 + c1 * yintH1S ).*yintS+ rho2*alpha*yintH1S; %new case of coinfection hiv+syphilis
%H2q = Y(:,4);% assignts the y-coordinates of …
residuals = (Hdata+HSdata – Hh-HShs)./2;
%subplot(1,2,2);
figure(3)
plot(tdata,Hdata,’r*’);
hold on
plot(tdata,Hh,’b-‘);
xlabel(‘Time in days’);
ylabel(‘Number of mono-HIV cases’);
axis([2009 2019 0 1000]);
legend(‘Data’, ‘Model estimation’);
figure(4)
plot(tdata,HSdata,’r*’);
hold on
plot(tdata,HShs,’b-‘);
xlabel(‘Time in days’);
ylabel(‘Number of Coinfection cases’);
axis([2009 2019 0 1000]);
legend(‘Data’, ‘Model estimation’);
function dy=modelhs(~,y,k)
delta = 0.01; % Taux de mortalité
delta_S = 0.05; % Taux de mort de Syphilis.
delta_H = 0.4;
Lambda =4.04 *100;
gamma=1.5;
phi_S =k(1);
phi_H =k(2);
c1 = k(3);
c2=k(4) ;
theta1 =k(5) ;
theta2 = k(6);
alpha = k(7);
beta = k(8);
rho1 = k(9);
rho2= k(10);
rho3=k(11);
dy = zeros(7,1);
%lambda_s=phi_S * ( y(2) + c2 * y(5))
%lambda_H= phi_H * ( y(3) + c1 * y(5) )
dy(1) = Lambda + gamma * y(2) – (phi_S * ( y(2) + c2 * y(5)) + phi_H * (y(3) + c1 * y(5)) + delta ) * y(1) ;%M
dy(2)= phi_S * ( y(2) + c2 * y(5) ) * y(1) – ( gamma + theta2 * phi_H * ( y(3) + c1 * y(5) ) + delta_S ) * y(2) ;%S
dy(3) = phi_H * ( y(3) + c1 * y(5) ) * y(1) + rho1 * gamma * y(5) – (theta1 * phi_S * ( y(2) + c2 * y(5)) + delta + delta_H + alpha) * y(3) ;%H1
dy(4) = alpha * y(3) – (beta + delta + delta_H) * y(4) ;%H2
dy(5) = theta2 * phi_H * ( y(3) + c1 * y(5) ) * y(2) + ( theta1 * phi_S * ( y(2) + c2 * y(5) ) ) * y(3) – ( rho1 * gamma + rho2 * alpha + delta_H + delta_S + delta ) * y(5) ;%H1S
dy(6)= rho2 * alpha * y(5) – ( rho3 * beta + delta_S + delta_H + delta ) * y(6) ;%H2S
dy(7)= beta * y(4) + rho3 * beta * y(6) – ( delta + delta_H ) * y(7) ;%C
end
function error_in_data = moderHS(k)
% Données spécifiques
specific_data = [
2009 2 8;
2010 10 22;
2011 30 45;
2012 111 75;
2013 125 96;
2014 255 192;
2015 379 227;
2016 384 238
2017 360 279;
2018 399 229;
2019 235 128
];
gamma = 1.5;
phi_S =k(1);
phi_H =k(2);
c1 = k(3);
c2=k(4) ;
theta1 =k(5) ;
theta2 = k(6);
alpha = k(7);
beta = k(8);
rho1 = k(9);
rho2= k(10);
rho3=k(11);
% Utilisez les données spécifiques
tdata = specific_data(:, 1);
Hdata = specific_data(:, 2);
HSdata = specific_data(:, 3);
tforward = 2009:1:2019;
[T, Y] = ode23s(@(t,y)(modelhs(t,y,k)),tforward,[ 5000.0 20.0 2.0 0.0 6.0 2.0 0.0 ]);
M = Y(:,1);
S = Y(:,2);
H1 = Y(:,3);
H2 = Y(:,4);
H1S=Y(:,5);
H2S=Y(:,6);
H=phi_H * ( H1 + c1 * H1S ).*M + rho1 * gamma*H1S + alpha* H2; % new cases from mono-HIV
HS=theta1*phi_S * ( S + c2 * H1S ).*H1 + theta2*phi_H * ( H1 + c1 * H1S ).*S+ rho2*alpha*H1S; %new case of coinfection hiv+syphilis
%H2q = Y(:,4);% assignts the y-coordinates of …
%the solution at
D=mean(Hdata).^2;
D1=mean(HSdata).^2;
A=(H – Hdata).^2;
B=(HS – HSdata).^2;
error_in_data =sum(A)./(11*D)+ sum(B)./(11*D1);
%%
end clear
close all
clc
% Données spécifiques
specific_data = [
2009 2 8;
2010 10 22;
2011 30 45;
2012 111 75;
2013 125 96;
2014 255 192;
2015 379 227;
2016 384 238
2017 360 279;
2018 399 229;
2019 235 128
];
% Utilisez les données spécifiques
tdata = specific_data(:, 1);
Hdata = specific_data(:, 2);
HSdata = specific_data(:, 3);
tforward = 2009:1:2019;
%tmeasure = [ 1:100:1001]’;
% initial values
gamma = 1.5;
phi_S = 0.0006; % transmission prob
phi_H = 0.000051; % trans proba
c1=3;
c2=1.5;
theta1 = 100; % djustment parameters for syph
theta2 = 4; %djustment parameters for hi
alpha = 0.6; % progression rate
beta = 0.2; %Complications rate
rho1 = 0.4; % adjustment parameters
rho2 = 1.5; % adjustment parameters
rho3 = 1.5; % adjustment parameters
k0 = [phi_S phi_H c1 c2 theta1 theta2 alpha beta rho1 rho2 rho3 ];
% solve equ with initial value of parameters
[t, Y] = ode23s(@(t, y)modelhs(t, y, k0), tforward, [ 5000.0 20.0 2.0 0.0 6.0 2.0 0.0 ]);
yintM = Y(:,1);
yintS = Y(:,2);
yintH1 = Y(:,3);
yintH2 = Y(:,4);
yintH1S=Y(:,5);
yintH2S=Y(:,6);
Hh=phi_H * ( yintH1 + c1 * yintH1S ).*yintM + rho1 * gamma * yintH1S + alpha* yintH2; % new cases from monoH
HShs=theta1*phi_S * ( yintS + c2 * yintH1S ).*yintH1 + theta2*phi_H * ( yintH1 + c1 * yintH1S ).*yintS+ rho2*alpha*yintH1S; %new case of co h-s
%H2q = Y(:,4);% assignts the y-coordinates of .
% Plotting specific data and solutions
% Display the results
figure(1)
%subplot(1,2,1);
plot(tdata, Hdata, ‘r*’);
hold on
plot(tdata, Hh, ‘b-‘);
xlabel(‘time in days’);
ylabel(‘Number of monhiv cases’);
axis([2009 2019 0 500]);
figure(2)
%subplot(1,2,1);
plot(tdata, HSdata, ‘r*’);
hold on
plot(tdata, HShs, ‘b-‘);
xlabel(‘time in days’);
ylabel(‘Number of Coinfection cases’);
axis([2009 2019 0 500]);
% Minimization routine using Nelder & Mead Simplex algorithm (a derivative-free method)
% Assigns the new values of parameters to k and the error to fval
% Minimization routine using Nelder & Mead Simplex algorithm (a derivative-free method)
% Assigns the new values of parameters to k and the error to fval
[k,fval] = fminsearch(@moderHS,k0)
%print final values of alpha and beta
disp(k);
%Draw the data with the final ODE
[T, Y] = ode45(@(t,y)(modelhs(t,y,k)),tforward,[ 5000.0 20.0 2.0 0.0 6.0 2.0 0.0 ]);
yintM = Y(:,1);
yintS = Y(:,2);
yintH1 = Y(:,3);
yintH2 = Y(:,4);
yintH1S=Y(:,5);
yintH2S=Y(:,6);
Hh=phi_H * ( yintH1 + c1 * yintH1S ).*yintM + rho1 * gamma * yintH1S + alpha* yintH2; % new cases from mono-HIV
HShs=theta1*phi_S * ( yintS + c2 * yintH1S ).*yintH1 + theta2*phi_H * ( yintH1 + c1 * yintH1S ).*yintS+ rho2*alpha*yintH1S; %new case of coinfection hiv+syphilis
%H2q = Y(:,4);% assignts the y-coordinates of …
residuals = (Hdata+HSdata – Hh-HShs)./2;
%subplot(1,2,2);
figure(3)
plot(tdata,Hdata,’r*’);
hold on
plot(tdata,Hh,’b-‘);
xlabel(‘Time in days’);
ylabel(‘Number of mono-HIV cases’);
axis([2009 2019 0 1000]);
legend(‘Data’, ‘Model estimation’);
figure(4)
plot(tdata,HSdata,’r*’);
hold on
plot(tdata,HShs,’b-‘);
xlabel(‘Time in days’);
ylabel(‘Number of Coinfection cases’);
axis([2009 2019 0 1000]);
legend(‘Data’, ‘Model estimation’);
function dy=modelhs(~,y,k)
delta = 0.01; % Taux de mortalité
delta_S = 0.05; % Taux de mort de Syphilis.
delta_H = 0.4;
Lambda =4.04 *100;
gamma=1.5;
phi_S =k(1);
phi_H =k(2);
c1 = k(3);
c2=k(4) ;
theta1 =k(5) ;
theta2 = k(6);
alpha = k(7);
beta = k(8);
rho1 = k(9);
rho2= k(10);
rho3=k(11);
dy = zeros(7,1);
%lambda_s=phi_S * ( y(2) + c2 * y(5))
%lambda_H= phi_H * ( y(3) + c1 * y(5) )
dy(1) = Lambda + gamma * y(2) – (phi_S * ( y(2) + c2 * y(5)) + phi_H * (y(3) + c1 * y(5)) + delta ) * y(1) ;%M
dy(2)= phi_S * ( y(2) + c2 * y(5) ) * y(1) – ( gamma + theta2 * phi_H * ( y(3) + c1 * y(5) ) + delta_S ) * y(2) ;%S
dy(3) = phi_H * ( y(3) + c1 * y(5) ) * y(1) + rho1 * gamma * y(5) – (theta1 * phi_S * ( y(2) + c2 * y(5)) + delta + delta_H + alpha) * y(3) ;%H1
dy(4) = alpha * y(3) – (beta + delta + delta_H) * y(4) ;%H2
dy(5) = theta2 * phi_H * ( y(3) + c1 * y(5) ) * y(2) + ( theta1 * phi_S * ( y(2) + c2 * y(5) ) ) * y(3) – ( rho1 * gamma + rho2 * alpha + delta_H + delta_S + delta ) * y(5) ;%H1S
dy(6)= rho2 * alpha * y(5) – ( rho3 * beta + delta_S + delta_H + delta ) * y(6) ;%H2S
dy(7)= beta * y(4) + rho3 * beta * y(6) – ( delta + delta_H ) * y(7) ;%C
end
function error_in_data = moderHS(k)
% Données spécifiques
specific_data = [
2009 2 8;
2010 10 22;
2011 30 45;
2012 111 75;
2013 125 96;
2014 255 192;
2015 379 227;
2016 384 238
2017 360 279;
2018 399 229;
2019 235 128
];
gamma = 1.5;
phi_S =k(1);
phi_H =k(2);
c1 = k(3);
c2=k(4) ;
theta1 =k(5) ;
theta2 = k(6);
alpha = k(7);
beta = k(8);
rho1 = k(9);
rho2= k(10);
rho3=k(11);
% Utilisez les données spécifiques
tdata = specific_data(:, 1);
Hdata = specific_data(:, 2);
HSdata = specific_data(:, 3);
tforward = 2009:1:2019;
[T, Y] = ode23s(@(t,y)(modelhs(t,y,k)),tforward,[ 5000.0 20.0 2.0 0.0 6.0 2.0 0.0 ]);
M = Y(:,1);
S = Y(:,2);
H1 = Y(:,3);
H2 = Y(:,4);
H1S=Y(:,5);
H2S=Y(:,6);
H=phi_H * ( H1 + c1 * H1S ).*M + rho1 * gamma*H1S + alpha* H2; % new cases from mono-HIV
HS=theta1*phi_S * ( S + c2 * H1S ).*H1 + theta2*phi_H * ( H1 + c1 * H1S ).*S+ rho2*alpha*H1S; %new case of coinfection hiv+syphilis
%H2q = Y(:,4);% assignts the y-coordinates of …
%the solution at
D=mean(Hdata).^2;
D1=mean(HSdata).^2;
A=(H – Hdata).^2;
B=(HS – HSdata).^2;
error_in_data =sum(A)./(11*D)+ sum(B)./(11*D1);
%%
end curve fitting, parameters estimation, optimization, multiple curve fitting MATLAB Answers — New Questions
How can I purchase a Student Version License if I don’t have a Credit Card?
How can I purchase a Student Version License if I don’t have a Credit Card?How can I purchase a Student Version License if I don’t have a Credit Card? How can I purchase a Student Version License if I don’t have a Credit Card? student, version, purchase, no, credit, card MATLAB Answers — New Questions
Why do I get an error when I try to acess the PDF files in the MATLAB 6.0 (R12) HelpDesk?
I get the following error when I try to acess the printable documentation, or PDF, files in the MATLAB 6.0 (R12) HelpDesk.
ERROR: Documentation in PDF format is located on your Documentation CD.
Insert the CD, then click OK to continue.
I installed all the documentation files when I installed MATLAB.I get the following error when I try to acess the printable documentation, or PDF, files in the MATLAB 6.0 (R12) HelpDesk.
ERROR: Documentation in PDF format is located on your Documentation CD.
Insert the CD, then click OK to continue.
I installed all the documentation files when I installed MATLAB. I get the following error when I try to acess the printable documentation, or PDF, files in the MATLAB 6.0 (R12) HelpDesk.
ERROR: Documentation in PDF format is located on your Documentation CD.
Insert the CD, then click OK to continue.
I installed all the documentation files when I installed MATLAB. pdf, doc, helpdesk, install MATLAB Answers — New Questions
How to calculate the determination coefficient R^2 with two matrix ?
hello I have two matrices A(i,j) and B (i,j). How to calculate for each i the covariance (A,B)? also calculate the determination coefficientR ^2?hello I have two matrices A(i,j) and B (i,j). How to calculate for each i the covariance (A,B)? also calculate the determination coefficientR ^2? hello I have two matrices A(i,j) and B (i,j). How to calculate for each i the covariance (A,B)? also calculate the determination coefficientR ^2? matrix, statistics MATLAB Answers — New Questions
On import high dimensional data from csv, how to assign them appropriate optimal datatypes automatically?
I am working with a dataset that has 30,000 features most of them are logocal datatypes.
I wish that when this data is imported to workspace an appropriate optimal datatypes is assiged automatically to each column(attributes).
I observe through the data cleaning tool that they are not being assigned the optimal datatypes
such as logical datatypes are assigned double( wasting alot of space).
Manualy assigning will be very tedious task because of 30 thousand features.
Moreover, other algorithms are demanding too much memory because of this such as feature ranking methods and machine learning algorithms
Th system i am using has 32GB of RAM.I am working with a dataset that has 30,000 features most of them are logocal datatypes.
I wish that when this data is imported to workspace an appropriate optimal datatypes is assiged automatically to each column(attributes).
I observe through the data cleaning tool that they are not being assigned the optimal datatypes
such as logical datatypes are assigned double( wasting alot of space).
Manualy assigning will be very tedious task because of 30 thousand features.
Moreover, other algorithms are demanding too much memory because of this such as feature ranking methods and machine learning algorithms
Th system i am using has 32GB of RAM. I am working with a dataset that has 30,000 features most of them are logocal datatypes.
I wish that when this data is imported to workspace an appropriate optimal datatypes is assiged automatically to each column(attributes).
I observe through the data cleaning tool that they are not being assigned the optimal datatypes
such as logical datatypes are assigned double( wasting alot of space).
Manualy assigning will be very tedious task because of 30 thousand features.
Moreover, other algorithms are demanding too much memory because of this such as feature ranking methods and machine learning algorithms
Th system i am using has 32GB of RAM. high dimansional data, optimal datatypes casting, importing high dimensional data MATLAB Answers — New Questions
Hi, I am trying to get a curve fit to real data. and I have had a lot of problems. I am using the fminsearch function to get an estimate of the parameters; my questions are: 1
clear
close all
clc
% Données spécifiques
specific_data = [
2009 2 8;
2010 10 22;
2011 30 45;
2012 111 75;
2013 125 96;
2014 255 192;
2015 379 227;
2016 384 238
2017 360 279;
2018 399 229;
2019 235 128
];
% Utilisez les données spécifiques
tdata = specific_data(:, 1);
Hdata = specific_data(:, 2);
HSdata = specific_data(:, 3);
tforward = 2009:1:2019;
%tmeasure = [ 1:100:1001]’;
% initial values
gamma = 1.5;
phi_S = 0.0006; % transmission prob
phi_H = 0.000051; % trans proba
c1=3;
c2=1.5;
theta1 = 100; % djustment parameters for syph
theta2 = 4; %djustment parameters for hi
alpha = 0.6; % progression rate
beta = 0.2; %Complications rate
rho1 = 0.4; % adjustment parameters
rho2 = 1.5; % adjustment parameters
rho3 = 1.5; % adjustment parameters
k0 = [phi_S phi_H c1 c2 theta1 theta2 alpha beta rho1 rho2 rho3 ];
% solve equ with initial value of parameters
[t, Y] = ode23s(@(t, y)modelhs(t, y, k0), tforward, [ 5000.0 20.0 2.0 0.0 6.0 2.0 0.0 ]);
yintM = Y(:,1);
yintS = Y(:,2);
yintH1 = Y(:,3);
yintH2 = Y(:,4);
yintH1S=Y(:,5);
yintH2S=Y(:,6);
Hh=phi_H * ( yintH1 + c1 * yintH1S ).*yintM + rho1 * gamma * yintH1S + alpha* yintH2; % new cases from monoH
HShs=theta1*phi_S * ( yintS + c2 * yintH1S ).*yintH1 + theta2*phi_H * ( yintH1 + c1 * yintH1S ).*yintS+ rho2*alpha*yintH1S; %new case of co h-s
%H2q = Y(:,4);% assignts the y-coordinates of .
% Plotting specific data and solutions
% Display the results
figure(1)
%subplot(1,2,1);
plot(tdata, Hdata, ‘r*’);
hold on
plot(tdata, Hh, ‘b-‘);
xlabel(‘time in days’);
ylabel(‘Number of monhiv cases’);
axis([2009 2019 0 500]);
figure(2)
%subplot(1,2,1);
plot(tdata, HSdata, ‘r*’);
hold on
plot(tdata, HShs, ‘b-‘);
xlabel(‘time in days’);
ylabel(‘Number of Coinfection cases’);
axis([2009 2019 0 500]);
% Minimization routine using Nelder & Mead Simplex algorithm (a derivative-free method)
% Assigns the new values of parameters to k and the error to fval
% Minimization routine using Nelder & Mead Simplex algorithm (a derivative-free method)
% Assigns the new values of parameters to k and the error to fval
[k,fval] = fminsearch(@moderHS,k0)
%print final values of alpha and beta
disp(k);
%Draw the data with the final ODE
[T, Y] = ode45(@(t,y)(modelhs(t,y,k)),tforward,[ 5000.0 20.0 2.0 0.0 6.0 2.0 0.0 ]);
yintM = Y(:,1);
yintS = Y(:,2);
yintH1 = Y(:,3);
yintH2 = Y(:,4);
yintH1S=Y(:,5);
yintH2S=Y(:,6);
Hh=phi_H * ( yintH1 + c1 * yintH1S ).*yintM + rho1 * gamma * yintH1S + alpha* yintH2; % new cases from mono-HIV
HShs=theta1*phi_S * ( yintS + c2 * yintH1S ).*yintH1 + theta2*phi_H * ( yintH1 + c1 * yintH1S ).*yintS+ rho2*alpha*yintH1S; %new case of coinfection hiv+syphilis
%H2q = Y(:,4);% assignts the y-coordinates of …
residuals = (Hdata+HSdata – Hh-HShs)./2;
%subplot(1,2,2);
figure(3)
plot(tdata,Hdata,’r*’);
hold on
plot(tdata,Hh,’b-‘);
xlabel(‘Time in days’);
ylabel(‘Number of mono-HIV cases’);
axis([2009 2019 0 1000]);
legend(‘Data’, ‘Model estimation’);
figure(4)
plot(tdata,HSdata,’r*’);
hold on
plot(tdata,HShs,’b-‘);
xlabel(‘Time in days’);
ylabel(‘Number of Coinfection cases’);
axis([2009 2019 0 1000]);
legend(‘Data’, ‘Model estimation’);
function dy=modelhs(~,y,k)
delta = 0.01; % Taux de mortalité
delta_S = 0.05; % Taux de mort de Syphilis.
delta_H = 0.4;
Lambda =4.04 *100;
gamma=1.5;
phi_S =k(1);
phi_H =k(2);
c1 = k(3);
c2=k(4) ;
theta1 =k(5) ;
theta2 = k(6);
alpha = k(7);
beta = k(8);
rho1 = k(9);
rho2= k(10);
rho3=k(11);
dy = zeros(7,1);
%lambda_s=phi_S * ( y(2) + c2 * y(5))
%lambda_H= phi_H * ( y(3) + c1 * y(5) )
dy(1) = Lambda + gamma * y(2) – (phi_S * ( y(2) + c2 * y(5)) + phi_H * (y(3) + c1 * y(5)) + delta ) * y(1) ;%M
dy(2)= phi_S * ( y(2) + c2 * y(5) ) * y(1) – ( gamma + theta2 * phi_H * ( y(3) + c1 * y(5) ) + delta_S ) * y(2) ;%S
dy(3) = phi_H * ( y(3) + c1 * y(5) ) * y(1) + rho1 * gamma * y(5) – (theta1 * phi_S * ( y(2) + c2 * y(5)) + delta + delta_H + alpha) * y(3) ;%H1
dy(4) = alpha * y(3) – (beta + delta + delta_H) * y(4) ;%H2
dy(5) = theta2 * phi_H * ( y(3) + c1 * y(5) ) * y(2) + ( theta1 * phi_S * ( y(2) + c2 * y(5) ) ) * y(3) – ( rho1 * gamma + rho2 * alpha + delta_H + delta_S + delta ) * y(5) ;%H1S
dy(6)= rho2 * alpha * y(5) – ( rho3 * beta + delta_S + delta_H + delta ) * y(6) ;%H2S
dy(7)= beta * y(4) + rho3 * beta * y(6) – ( delta + delta_H ) * y(7) ;%C
end
function error_in_data = moderHS(k)
% Données spécifiques
specific_data = [
2009 2 8;
2010 10 22;
2011 30 45;
2012 111 75;
2013 125 96;
2014 255 192;
2015 379 227;
2016 384 238
2017 360 279;
2018 399 229;
2019 235 128
];
gamma = 1.5;
phi_S =k(1);
phi_H =k(2);
c1 = k(3);
c2=k(4) ;
theta1 =k(5) ;
theta2 = k(6);
alpha = k(7);
beta = k(8);
rho1 = k(9);
rho2= k(10);
rho3=k(11);
% Utilisez les données spécifiques
tdata = specific_data(:, 1);
Hdata = specific_data(:, 2);
HSdata = specific_data(:, 3);
tforward = 2009:1:2019;
[T, Y] = ode23s(@(t,y)(modelhs(t,y,k)),tforward,[ 5000.0 20.0 2.0 0.0 6.0 2.0 0.0 ]);
M = Y(:,1);
S = Y(:,2);
H1 = Y(:,3);
H2 = Y(:,4);
H1S=Y(:,5);
H2S=Y(:,6);
H=phi_H * ( H1 + c1 * H1S ).*M + rho1 * gamma*H1S + alpha* H2; % new cases from mono-HIV
HS=theta1*phi_S * ( S + c2 * H1S ).*H1 + theta2*phi_H * ( H1 + c1 * H1S ).*S+ rho2*alpha*H1S; %new case of coinfection hiv+syphilis
%H2q = Y(:,4);% assignts the y-coordinates of …
%the solution at
D=mean(Hdata).^2;
D1=mean(HSdata).^2;
A=(H – Hdata).^2;
B=(HS – HSdata).^2;
error_in_data =sum(A)./(11*D)+ sum(B)./(11*D1);
%%
endclear
close all
clc
% Données spécifiques
specific_data = [
2009 2 8;
2010 10 22;
2011 30 45;
2012 111 75;
2013 125 96;
2014 255 192;
2015 379 227;
2016 384 238
2017 360 279;
2018 399 229;
2019 235 128
];
% Utilisez les données spécifiques
tdata = specific_data(:, 1);
Hdata = specific_data(:, 2);
HSdata = specific_data(:, 3);
tforward = 2009:1:2019;
%tmeasure = [ 1:100:1001]’;
% initial values
gamma = 1.5;
phi_S = 0.0006; % transmission prob
phi_H = 0.000051; % trans proba
c1=3;
c2=1.5;
theta1 = 100; % djustment parameters for syph
theta2 = 4; %djustment parameters for hi
alpha = 0.6; % progression rate
beta = 0.2; %Complications rate
rho1 = 0.4; % adjustment parameters
rho2 = 1.5; % adjustment parameters
rho3 = 1.5; % adjustment parameters
k0 = [phi_S phi_H c1 c2 theta1 theta2 alpha beta rho1 rho2 rho3 ];
% solve equ with initial value of parameters
[t, Y] = ode23s(@(t, y)modelhs(t, y, k0), tforward, [ 5000.0 20.0 2.0 0.0 6.0 2.0 0.0 ]);
yintM = Y(:,1);
yintS = Y(:,2);
yintH1 = Y(:,3);
yintH2 = Y(:,4);
yintH1S=Y(:,5);
yintH2S=Y(:,6);
Hh=phi_H * ( yintH1 + c1 * yintH1S ).*yintM + rho1 * gamma * yintH1S + alpha* yintH2; % new cases from monoH
HShs=theta1*phi_S * ( yintS + c2 * yintH1S ).*yintH1 + theta2*phi_H * ( yintH1 + c1 * yintH1S ).*yintS+ rho2*alpha*yintH1S; %new case of co h-s
%H2q = Y(:,4);% assignts the y-coordinates of .
% Plotting specific data and solutions
% Display the results
figure(1)
%subplot(1,2,1);
plot(tdata, Hdata, ‘r*’);
hold on
plot(tdata, Hh, ‘b-‘);
xlabel(‘time in days’);
ylabel(‘Number of monhiv cases’);
axis([2009 2019 0 500]);
figure(2)
%subplot(1,2,1);
plot(tdata, HSdata, ‘r*’);
hold on
plot(tdata, HShs, ‘b-‘);
xlabel(‘time in days’);
ylabel(‘Number of Coinfection cases’);
axis([2009 2019 0 500]);
% Minimization routine using Nelder & Mead Simplex algorithm (a derivative-free method)
% Assigns the new values of parameters to k and the error to fval
% Minimization routine using Nelder & Mead Simplex algorithm (a derivative-free method)
% Assigns the new values of parameters to k and the error to fval
[k,fval] = fminsearch(@moderHS,k0)
%print final values of alpha and beta
disp(k);
%Draw the data with the final ODE
[T, Y] = ode45(@(t,y)(modelhs(t,y,k)),tforward,[ 5000.0 20.0 2.0 0.0 6.0 2.0 0.0 ]);
yintM = Y(:,1);
yintS = Y(:,2);
yintH1 = Y(:,3);
yintH2 = Y(:,4);
yintH1S=Y(:,5);
yintH2S=Y(:,6);
Hh=phi_H * ( yintH1 + c1 * yintH1S ).*yintM + rho1 * gamma * yintH1S + alpha* yintH2; % new cases from mono-HIV
HShs=theta1*phi_S * ( yintS + c2 * yintH1S ).*yintH1 + theta2*phi_H * ( yintH1 + c1 * yintH1S ).*yintS+ rho2*alpha*yintH1S; %new case of coinfection hiv+syphilis
%H2q = Y(:,4);% assignts the y-coordinates of …
residuals = (Hdata+HSdata – Hh-HShs)./2;
%subplot(1,2,2);
figure(3)
plot(tdata,Hdata,’r*’);
hold on
plot(tdata,Hh,’b-‘);
xlabel(‘Time in days’);
ylabel(‘Number of mono-HIV cases’);
axis([2009 2019 0 1000]);
legend(‘Data’, ‘Model estimation’);
figure(4)
plot(tdata,HSdata,’r*’);
hold on
plot(tdata,HShs,’b-‘);
xlabel(‘Time in days’);
ylabel(‘Number of Coinfection cases’);
axis([2009 2019 0 1000]);
legend(‘Data’, ‘Model estimation’);
function dy=modelhs(~,y,k)
delta = 0.01; % Taux de mortalité
delta_S = 0.05; % Taux de mort de Syphilis.
delta_H = 0.4;
Lambda =4.04 *100;
gamma=1.5;
phi_S =k(1);
phi_H =k(2);
c1 = k(3);
c2=k(4) ;
theta1 =k(5) ;
theta2 = k(6);
alpha = k(7);
beta = k(8);
rho1 = k(9);
rho2= k(10);
rho3=k(11);
dy = zeros(7,1);
%lambda_s=phi_S * ( y(2) + c2 * y(5))
%lambda_H= phi_H * ( y(3) + c1 * y(5) )
dy(1) = Lambda + gamma * y(2) – (phi_S * ( y(2) + c2 * y(5)) + phi_H * (y(3) + c1 * y(5)) + delta ) * y(1) ;%M
dy(2)= phi_S * ( y(2) + c2 * y(5) ) * y(1) – ( gamma + theta2 * phi_H * ( y(3) + c1 * y(5) ) + delta_S ) * y(2) ;%S
dy(3) = phi_H * ( y(3) + c1 * y(5) ) * y(1) + rho1 * gamma * y(5) – (theta1 * phi_S * ( y(2) + c2 * y(5)) + delta + delta_H + alpha) * y(3) ;%H1
dy(4) = alpha * y(3) – (beta + delta + delta_H) * y(4) ;%H2
dy(5) = theta2 * phi_H * ( y(3) + c1 * y(5) ) * y(2) + ( theta1 * phi_S * ( y(2) + c2 * y(5) ) ) * y(3) – ( rho1 * gamma + rho2 * alpha + delta_H + delta_S + delta ) * y(5) ;%H1S
dy(6)= rho2 * alpha * y(5) – ( rho3 * beta + delta_S + delta_H + delta ) * y(6) ;%H2S
dy(7)= beta * y(4) + rho3 * beta * y(6) – ( delta + delta_H ) * y(7) ;%C
end
function error_in_data = moderHS(k)
% Données spécifiques
specific_data = [
2009 2 8;
2010 10 22;
2011 30 45;
2012 111 75;
2013 125 96;
2014 255 192;
2015 379 227;
2016 384 238
2017 360 279;
2018 399 229;
2019 235 128
];
gamma = 1.5;
phi_S =k(1);
phi_H =k(2);
c1 = k(3);
c2=k(4) ;
theta1 =k(5) ;
theta2 = k(6);
alpha = k(7);
beta = k(8);
rho1 = k(9);
rho2= k(10);
rho3=k(11);
% Utilisez les données spécifiques
tdata = specific_data(:, 1);
Hdata = specific_data(:, 2);
HSdata = specific_data(:, 3);
tforward = 2009:1:2019;
[T, Y] = ode23s(@(t,y)(modelhs(t,y,k)),tforward,[ 5000.0 20.0 2.0 0.0 6.0 2.0 0.0 ]);
M = Y(:,1);
S = Y(:,2);
H1 = Y(:,3);
H2 = Y(:,4);
H1S=Y(:,5);
H2S=Y(:,6);
H=phi_H * ( H1 + c1 * H1S ).*M + rho1 * gamma*H1S + alpha* H2; % new cases from mono-HIV
HS=theta1*phi_S * ( S + c2 * H1S ).*H1 + theta2*phi_H * ( H1 + c1 * H1S ).*S+ rho2*alpha*H1S; %new case of coinfection hiv+syphilis
%H2q = Y(:,4);% assignts the y-coordinates of …
%the solution at
D=mean(Hdata).^2;
D1=mean(HSdata).^2;
A=(H – Hdata).^2;
B=(HS – HSdata).^2;
error_in_data =sum(A)./(11*D)+ sum(B)./(11*D1);
%%
end clear
close all
clc
% Données spécifiques
specific_data = [
2009 2 8;
2010 10 22;
2011 30 45;
2012 111 75;
2013 125 96;
2014 255 192;
2015 379 227;
2016 384 238
2017 360 279;
2018 399 229;
2019 235 128
];
% Utilisez les données spécifiques
tdata = specific_data(:, 1);
Hdata = specific_data(:, 2);
HSdata = specific_data(:, 3);
tforward = 2009:1:2019;
%tmeasure = [ 1:100:1001]’;
% initial values
gamma = 1.5;
phi_S = 0.0006; % transmission prob
phi_H = 0.000051; % trans proba
c1=3;
c2=1.5;
theta1 = 100; % djustment parameters for syph
theta2 = 4; %djustment parameters for hi
alpha = 0.6; % progression rate
beta = 0.2; %Complications rate
rho1 = 0.4; % adjustment parameters
rho2 = 1.5; % adjustment parameters
rho3 = 1.5; % adjustment parameters
k0 = [phi_S phi_H c1 c2 theta1 theta2 alpha beta rho1 rho2 rho3 ];
% solve equ with initial value of parameters
[t, Y] = ode23s(@(t, y)modelhs(t, y, k0), tforward, [ 5000.0 20.0 2.0 0.0 6.0 2.0 0.0 ]);
yintM = Y(:,1);
yintS = Y(:,2);
yintH1 = Y(:,3);
yintH2 = Y(:,4);
yintH1S=Y(:,5);
yintH2S=Y(:,6);
Hh=phi_H * ( yintH1 + c1 * yintH1S ).*yintM + rho1 * gamma * yintH1S + alpha* yintH2; % new cases from monoH
HShs=theta1*phi_S * ( yintS + c2 * yintH1S ).*yintH1 + theta2*phi_H * ( yintH1 + c1 * yintH1S ).*yintS+ rho2*alpha*yintH1S; %new case of co h-s
%H2q = Y(:,4);% assignts the y-coordinates of .
% Plotting specific data and solutions
% Display the results
figure(1)
%subplot(1,2,1);
plot(tdata, Hdata, ‘r*’);
hold on
plot(tdata, Hh, ‘b-‘);
xlabel(‘time in days’);
ylabel(‘Number of monhiv cases’);
axis([2009 2019 0 500]);
figure(2)
%subplot(1,2,1);
plot(tdata, HSdata, ‘r*’);
hold on
plot(tdata, HShs, ‘b-‘);
xlabel(‘time in days’);
ylabel(‘Number of Coinfection cases’);
axis([2009 2019 0 500]);
% Minimization routine using Nelder & Mead Simplex algorithm (a derivative-free method)
% Assigns the new values of parameters to k and the error to fval
% Minimization routine using Nelder & Mead Simplex algorithm (a derivative-free method)
% Assigns the new values of parameters to k and the error to fval
[k,fval] = fminsearch(@moderHS,k0)
%print final values of alpha and beta
disp(k);
%Draw the data with the final ODE
[T, Y] = ode45(@(t,y)(modelhs(t,y,k)),tforward,[ 5000.0 20.0 2.0 0.0 6.0 2.0 0.0 ]);
yintM = Y(:,1);
yintS = Y(:,2);
yintH1 = Y(:,3);
yintH2 = Y(:,4);
yintH1S=Y(:,5);
yintH2S=Y(:,6);
Hh=phi_H * ( yintH1 + c1 * yintH1S ).*yintM + rho1 * gamma * yintH1S + alpha* yintH2; % new cases from mono-HIV
HShs=theta1*phi_S * ( yintS + c2 * yintH1S ).*yintH1 + theta2*phi_H * ( yintH1 + c1 * yintH1S ).*yintS+ rho2*alpha*yintH1S; %new case of coinfection hiv+syphilis
%H2q = Y(:,4);% assignts the y-coordinates of …
residuals = (Hdata+HSdata – Hh-HShs)./2;
%subplot(1,2,2);
figure(3)
plot(tdata,Hdata,’r*’);
hold on
plot(tdata,Hh,’b-‘);
xlabel(‘Time in days’);
ylabel(‘Number of mono-HIV cases’);
axis([2009 2019 0 1000]);
legend(‘Data’, ‘Model estimation’);
figure(4)
plot(tdata,HSdata,’r*’);
hold on
plot(tdata,HShs,’b-‘);
xlabel(‘Time in days’);
ylabel(‘Number of Coinfection cases’);
axis([2009 2019 0 1000]);
legend(‘Data’, ‘Model estimation’);
function dy=modelhs(~,y,k)
delta = 0.01; % Taux de mortalité
delta_S = 0.05; % Taux de mort de Syphilis.
delta_H = 0.4;
Lambda =4.04 *100;
gamma=1.5;
phi_S =k(1);
phi_H =k(2);
c1 = k(3);
c2=k(4) ;
theta1 =k(5) ;
theta2 = k(6);
alpha = k(7);
beta = k(8);
rho1 = k(9);
rho2= k(10);
rho3=k(11);
dy = zeros(7,1);
%lambda_s=phi_S * ( y(2) + c2 * y(5))
%lambda_H= phi_H * ( y(3) + c1 * y(5) )
dy(1) = Lambda + gamma * y(2) – (phi_S * ( y(2) + c2 * y(5)) + phi_H * (y(3) + c1 * y(5)) + delta ) * y(1) ;%M
dy(2)= phi_S * ( y(2) + c2 * y(5) ) * y(1) – ( gamma + theta2 * phi_H * ( y(3) + c1 * y(5) ) + delta_S ) * y(2) ;%S
dy(3) = phi_H * ( y(3) + c1 * y(5) ) * y(1) + rho1 * gamma * y(5) – (theta1 * phi_S * ( y(2) + c2 * y(5)) + delta + delta_H + alpha) * y(3) ;%H1
dy(4) = alpha * y(3) – (beta + delta + delta_H) * y(4) ;%H2
dy(5) = theta2 * phi_H * ( y(3) + c1 * y(5) ) * y(2) + ( theta1 * phi_S * ( y(2) + c2 * y(5) ) ) * y(3) – ( rho1 * gamma + rho2 * alpha + delta_H + delta_S + delta ) * y(5) ;%H1S
dy(6)= rho2 * alpha * y(5) – ( rho3 * beta + delta_S + delta_H + delta ) * y(6) ;%H2S
dy(7)= beta * y(4) + rho3 * beta * y(6) – ( delta + delta_H ) * y(7) ;%C
end
function error_in_data = moderHS(k)
% Données spécifiques
specific_data = [
2009 2 8;
2010 10 22;
2011 30 45;
2012 111 75;
2013 125 96;
2014 255 192;
2015 379 227;
2016 384 238
2017 360 279;
2018 399 229;
2019 235 128
];
gamma = 1.5;
phi_S =k(1);
phi_H =k(2);
c1 = k(3);
c2=k(4) ;
theta1 =k(5) ;
theta2 = k(6);
alpha = k(7);
beta = k(8);
rho1 = k(9);
rho2= k(10);
rho3=k(11);
% Utilisez les données spécifiques
tdata = specific_data(:, 1);
Hdata = specific_data(:, 2);
HSdata = specific_data(:, 3);
tforward = 2009:1:2019;
[T, Y] = ode23s(@(t,y)(modelhs(t,y,k)),tforward,[ 5000.0 20.0 2.0 0.0 6.0 2.0 0.0 ]);
M = Y(:,1);
S = Y(:,2);
H1 = Y(:,3);
H2 = Y(:,4);
H1S=Y(:,5);
H2S=Y(:,6);
H=phi_H * ( H1 + c1 * H1S ).*M + rho1 * gamma*H1S + alpha* H2; % new cases from mono-HIV
HS=theta1*phi_S * ( S + c2 * H1S ).*H1 + theta2*phi_H * ( H1 + c1 * H1S ).*S+ rho2*alpha*H1S; %new case of coinfection hiv+syphilis
%H2q = Y(:,4);% assignts the y-coordinates of …
%the solution at
D=mean(Hdata).^2;
D1=mean(HSdata).^2;
A=(H – Hdata).^2;
B=(HS – HSdata).^2;
error_in_data =sum(A)./(11*D)+ sum(B)./(11*D1);
%%
end fiting, code, estimation of parameters, optimization MATLAB Answers — New Questions
I’m using VIT transformer in my code. How to convert the output of 1D layer of VIT into 2D with format SSCB?
I used the following code from Matlab answer to solve the errorrs that shown in the attached figure.
(Samuel Somuyiwa on 24 Jul 2023)
% Get Vision Transformer model
net = visionTransformer;
% Create dummy input
input = dlarray(rand(384,384,3),’SSCB’);
% Obtain output embedding from last layerNormalizationLayer
out = forward(net, input, Outputs=’encoder_norm’);
% Reshape output patch embedding
out = reshapePatchEmbedding(out);
function out = reshapePatchEmbedding(in)
% Remove output embedding corresponding to class token from input
out = in(2:end,:,:);
% Reshape resulting embedding to input format
WH = sqrt(size(out, 1));
C = size(out, 2);
out = reshape(out, WH, WH, C, []); % Shape is W x H x C x N
out = permute(out, [2, 1, 3, 4]); % Shape is H x W x C x N
% Convert to formatted dlarray
out = dlarray(out, ‘SSCB’);
endI used the following code from Matlab answer to solve the errorrs that shown in the attached figure.
(Samuel Somuyiwa on 24 Jul 2023)
% Get Vision Transformer model
net = visionTransformer;
% Create dummy input
input = dlarray(rand(384,384,3),’SSCB’);
% Obtain output embedding from last layerNormalizationLayer
out = forward(net, input, Outputs=’encoder_norm’);
% Reshape output patch embedding
out = reshapePatchEmbedding(out);
function out = reshapePatchEmbedding(in)
% Remove output embedding corresponding to class token from input
out = in(2:end,:,:);
% Reshape resulting embedding to input format
WH = sqrt(size(out, 1));
C = size(out, 2);
out = reshape(out, WH, WH, C, []); % Shape is W x H x C x N
out = permute(out, [2, 1, 3, 4]); % Shape is H x W x C x N
% Convert to formatted dlarray
out = dlarray(out, ‘SSCB’);
end I used the following code from Matlab answer to solve the errorrs that shown in the attached figure.
(Samuel Somuyiwa on 24 Jul 2023)
% Get Vision Transformer model
net = visionTransformer;
% Create dummy input
input = dlarray(rand(384,384,3),’SSCB’);
% Obtain output embedding from last layerNormalizationLayer
out = forward(net, input, Outputs=’encoder_norm’);
% Reshape output patch embedding
out = reshapePatchEmbedding(out);
function out = reshapePatchEmbedding(in)
% Remove output embedding corresponding to class token from input
out = in(2:end,:,:);
% Reshape resulting embedding to input format
WH = sqrt(size(out, 1));
C = size(out, 2);
out = reshape(out, WH, WH, C, []); % Shape is W x H x C x N
out = permute(out, [2, 1, 3, 4]); % Shape is H x W x C x N
% Convert to formatted dlarray
out = dlarray(out, ‘SSCB’);
end deep learning MATLAB Answers — New Questions
I want to use the multicore function of Simulink to accelarate my simulation. Having errors when profiling. It can not find the header file?
This the error shown in matlab command windows. I don’t konw how to solve this!
cpp: e:multicoretestnewmaintest grt rtwrt main.c:22 Could not find include file <processthreadsapi.h>
Error rt main.c: 287 operands of= have illegal types ‘pointer to void’ and ‘int’
Error rt main.c: 360 operands of= have illegal types ‘pointer to void’ and ‘int’
2 errors, 1 warning
The line 287 and Line 360 of rt_main.c is
orTimer = CreateWaitableTimer((NULL), false, (NULL));This the error shown in matlab command windows. I don’t konw how to solve this!
cpp: e:multicoretestnewmaintest grt rtwrt main.c:22 Could not find include file <processthreadsapi.h>
Error rt main.c: 287 operands of= have illegal types ‘pointer to void’ and ‘int’
Error rt main.c: 360 operands of= have illegal types ‘pointer to void’ and ‘int’
2 errors, 1 warning
The line 287 and Line 360 of rt_main.c is
orTimer = CreateWaitableTimer((NULL), false, (NULL)); This the error shown in matlab command windows. I don’t konw how to solve this!
cpp: e:multicoretestnewmaintest grt rtwrt main.c:22 Could not find include file <processthreadsapi.h>
Error rt main.c: 287 operands of= have illegal types ‘pointer to void’ and ‘int’
Error rt main.c: 360 operands of= have illegal types ‘pointer to void’ and ‘int’
2 errors, 1 warning
The line 287 and Line 360 of rt_main.c is
orTimer = CreateWaitableTimer((NULL), false, (NULL)); multicore, concurrent execution MATLAB Answers — New Questions
plotting multiple boxplots in the same figure window
I have 10 vectors of temperature data, all different lengths, that I want to make boxplots of and plot them all in the same figure window. How do I do this?I have 10 vectors of temperature data, all different lengths, that I want to make boxplots of and plot them all in the same figure window. How do I do this? I have 10 vectors of temperature data, all different lengths, that I want to make boxplots of and plot them all in the same figure window. How do I do this? boxplots, multiple vectors MATLAB Answers — New Questions
maximum clique problem solve
Maximum Clique
People in the social network are identified by unique IDs, consecutive integers from 1 to N. Who follows who is captured in a cell array called sn: the ii th element of sn is a vector that contains a list of IDs the person with ID ii follows. You may assume that these lists are ordered in ascending order by ID. Note that the follows relationship is not necessarily symmetrical: if person A follows person B, person B may or may not follow person A. :
function clique = max_clique(graph, clique)
if nargin < 2
clique = [];
end
max_clq = clique;
if isempty(clique)
for ii= 1:length(graph)
clq = max_clique(graph,ii);
if length(clq) > length(max_clq)
max_clq = clq;
end
end
else
for node=1:length(graph)
if isempty(find(node==clique))
if check_clique(clique,node,graph)
clq = max_clique(graph, [clique node]);
if length(clq) > length(max_clq)
max_clique == clq
end
end
end
end
end
clique = max_clq;
end
function ok = check_clique(clq,node,graph)
ok = false;
for ii=1:length(clq)
if isempty(find(clq(ii) == graph{node})) || isempty (find(node == graph{clq(ii)}))
return;
end
end
ok = true;
end
Unfortunately, it is too slow and the grader will time out. Your task is to modify the code to speed it up. Remember, the question to ask: am I doing any unncessary work? Call the modified function max_clique. (Hint: when we try to expand the current clique, do we really need to consider all the nodes?)
Please solve this problem with entire new code that is fast.Maximum Clique
People in the social network are identified by unique IDs, consecutive integers from 1 to N. Who follows who is captured in a cell array called sn: the ii th element of sn is a vector that contains a list of IDs the person with ID ii follows. You may assume that these lists are ordered in ascending order by ID. Note that the follows relationship is not necessarily symmetrical: if person A follows person B, person B may or may not follow person A. :
function clique = max_clique(graph, clique)
if nargin < 2
clique = [];
end
max_clq = clique;
if isempty(clique)
for ii= 1:length(graph)
clq = max_clique(graph,ii);
if length(clq) > length(max_clq)
max_clq = clq;
end
end
else
for node=1:length(graph)
if isempty(find(node==clique))
if check_clique(clique,node,graph)
clq = max_clique(graph, [clique node]);
if length(clq) > length(max_clq)
max_clique == clq
end
end
end
end
end
clique = max_clq;
end
function ok = check_clique(clq,node,graph)
ok = false;
for ii=1:length(clq)
if isempty(find(clq(ii) == graph{node})) || isempty (find(node == graph{clq(ii)}))
return;
end
end
ok = true;
end
Unfortunately, it is too slow and the grader will time out. Your task is to modify the code to speed it up. Remember, the question to ask: am I doing any unncessary work? Call the modified function max_clique. (Hint: when we try to expand the current clique, do we really need to consider all the nodes?)
Please solve this problem with entire new code that is fast. Maximum Clique
People in the social network are identified by unique IDs, consecutive integers from 1 to N. Who follows who is captured in a cell array called sn: the ii th element of sn is a vector that contains a list of IDs the person with ID ii follows. You may assume that these lists are ordered in ascending order by ID. Note that the follows relationship is not necessarily symmetrical: if person A follows person B, person B may or may not follow person A. :
function clique = max_clique(graph, clique)
if nargin < 2
clique = [];
end
max_clq = clique;
if isempty(clique)
for ii= 1:length(graph)
clq = max_clique(graph,ii);
if length(clq) > length(max_clq)
max_clq = clq;
end
end
else
for node=1:length(graph)
if isempty(find(node==clique))
if check_clique(clique,node,graph)
clq = max_clique(graph, [clique node]);
if length(clq) > length(max_clq)
max_clique == clq
end
end
end
end
end
clique = max_clq;
end
function ok = check_clique(clq,node,graph)
ok = false;
for ii=1:length(clq)
if isempty(find(clq(ii) == graph{node})) || isempty (find(node == graph{clq(ii)}))
return;
end
end
ok = true;
end
Unfortunately, it is too slow and the grader will time out. Your task is to modify the code to speed it up. Remember, the question to ask: am I doing any unncessary work? Call the modified function max_clique. (Hint: when we try to expand the current clique, do we really need to consider all the nodes?)
Please solve this problem with entire new code that is fast. maximum_clique MATLAB Answers — New Questions
Profiling of inefficient recursive Fibonacci series function
I am asked to profile an intentionally inefficient code. Following code will overtime with a huge input:
function f = fibo(n)
if n <= 2
f = 1;
else
f = fibo(n-2) + fibo(n-1);
end
end
I used a persistente variable, to create an array that reflects the recursion calls:
function [f, trace]=fibo_trace(n,v)%with persistent variable ‘trc’
persistent trc;
if isempty(trc)
trc=v;
end
if n<=2
trc=[trc n];
f=1;
else
trc=[trc n];
f=fibo_trace(n-2)+fibo_trace(n-1);
end
trace=trc;
end
That works flawlessly when I run the function with followin code:
[f trace] = fibo_trace(6,[])
And this is what the code returns:
f = 8
trace = 6 4 2 3 1 2 5 3 1 2 4 2 3 1 2,
which is OK, since the trace vector shows how inefficient the original code is. Now my problem is, it is an assigment for a MOOC platform and the solution with the persistent variable won’t work because the the automated grader will run the function a number of times with random inputs and it will not clear the function. Without the persistent variable I must split the recursive calls in two code lines and I am struggling now to compute the nth fibonacci number:
Can anyone give a clue? The creation of the array works but I honestly don’t know how to deal with the two recursive call lines to compute the fibonacci.I am asked to profile an intentionally inefficient code. Following code will overtime with a huge input:
function f = fibo(n)
if n <= 2
f = 1;
else
f = fibo(n-2) + fibo(n-1);
end
end
I used a persistente variable, to create an array that reflects the recursion calls:
function [f, trace]=fibo_trace(n,v)%with persistent variable ‘trc’
persistent trc;
if isempty(trc)
trc=v;
end
if n<=2
trc=[trc n];
f=1;
else
trc=[trc n];
f=fibo_trace(n-2)+fibo_trace(n-1);
end
trace=trc;
end
That works flawlessly when I run the function with followin code:
[f trace] = fibo_trace(6,[])
And this is what the code returns:
f = 8
trace = 6 4 2 3 1 2 5 3 1 2 4 2 3 1 2,
which is OK, since the trace vector shows how inefficient the original code is. Now my problem is, it is an assigment for a MOOC platform and the solution with the persistent variable won’t work because the the automated grader will run the function a number of times with random inputs and it will not clear the function. Without the persistent variable I must split the recursive calls in two code lines and I am struggling now to compute the nth fibonacci number:
Can anyone give a clue? The creation of the array works but I honestly don’t know how to deal with the two recursive call lines to compute the fibonacci. I am asked to profile an intentionally inefficient code. Following code will overtime with a huge input:
function f = fibo(n)
if n <= 2
f = 1;
else
f = fibo(n-2) + fibo(n-1);
end
end
I used a persistente variable, to create an array that reflects the recursion calls:
function [f, trace]=fibo_trace(n,v)%with persistent variable ‘trc’
persistent trc;
if isempty(trc)
trc=v;
end
if n<=2
trc=[trc n];
f=1;
else
trc=[trc n];
f=fibo_trace(n-2)+fibo_trace(n-1);
end
trace=trc;
end
That works flawlessly when I run the function with followin code:
[f trace] = fibo_trace(6,[])
And this is what the code returns:
f = 8
trace = 6 4 2 3 1 2 5 3 1 2 4 2 3 1 2,
which is OK, since the trace vector shows how inefficient the original code is. Now my problem is, it is an assigment for a MOOC platform and the solution with the persistent variable won’t work because the the automated grader will run the function a number of times with random inputs and it will not clear the function. Without the persistent variable I must split the recursive calls in two code lines and I am struggling now to compute the nth fibonacci number:
Can anyone give a clue? The creation of the array works but I honestly don’t know how to deal with the two recursive call lines to compute the fibonacci. fibonacci, recursion, homework MATLAB Answers — New Questions
How to set up the Matrix variables to use Options = optimoptions(‘lsqcurvefit’,’algorithm’,’levenberg-marquardt’)
I have two sets of M1 and M2 vectors (1×20) of experimental values that correspond to two sets of K1 and K2 inputs (1×20) respectively. Theoretlcal values of M1 and M2 (call them M1T and M2T) have a relationship with K1 and K2 such that M1-T is a function of K1 and K2, and M2-T is also a function of K1 and K2 with a series of a1 to a6 coefficients.
I am trying to find those a1 to a6 coefficients by minimizing the error function Total Error = (M1 – M1T)^2 + (M2-M2T)^2 by the use of
options = optimoptions(‘lsqcurvefit’,’Algorithm’,’levenberg-marquardt’), however, I don’t know how to set up my variables into these names/function (i.e. don’t know the approriate coding syntax).
As an example;
the inputs are: M1 = [ i1 i2 i3 ………… i20], M2 = [ i1 i2 i3 ………….i20], K1 = [ i1 i2 i3 ………… i20], K2 = [ i1 i2 i3 ………….i20],
the relationship between theroretical values of M1, M2 and the K1 and K2 are:
M1T(i) = a1*K1(i) + a2*K1(i)*K2(i) + a3*K2(i) + a4*(K1(i))^2
M2T(i) = a2*K2(i) + a2*K1(i) + a5*(K2(i))^2 + a6*K1(i)*K2(i)I have two sets of M1 and M2 vectors (1×20) of experimental values that correspond to two sets of K1 and K2 inputs (1×20) respectively. Theoretlcal values of M1 and M2 (call them M1T and M2T) have a relationship with K1 and K2 such that M1-T is a function of K1 and K2, and M2-T is also a function of K1 and K2 with a series of a1 to a6 coefficients.
I am trying to find those a1 to a6 coefficients by minimizing the error function Total Error = (M1 – M1T)^2 + (M2-M2T)^2 by the use of
options = optimoptions(‘lsqcurvefit’,’Algorithm’,’levenberg-marquardt’), however, I don’t know how to set up my variables into these names/function (i.e. don’t know the approriate coding syntax).
As an example;
the inputs are: M1 = [ i1 i2 i3 ………… i20], M2 = [ i1 i2 i3 ………….i20], K1 = [ i1 i2 i3 ………… i20], K2 = [ i1 i2 i3 ………….i20],
the relationship between theroretical values of M1, M2 and the K1 and K2 are:
M1T(i) = a1*K1(i) + a2*K1(i)*K2(i) + a3*K2(i) + a4*(K1(i))^2
M2T(i) = a2*K2(i) + a2*K1(i) + a5*(K2(i))^2 + a6*K1(i)*K2(i) I have two sets of M1 and M2 vectors (1×20) of experimental values that correspond to two sets of K1 and K2 inputs (1×20) respectively. Theoretlcal values of M1 and M2 (call them M1T and M2T) have a relationship with K1 and K2 such that M1-T is a function of K1 and K2, and M2-T is also a function of K1 and K2 with a series of a1 to a6 coefficients.
I am trying to find those a1 to a6 coefficients by minimizing the error function Total Error = (M1 – M1T)^2 + (M2-M2T)^2 by the use of
options = optimoptions(‘lsqcurvefit’,’Algorithm’,’levenberg-marquardt’), however, I don’t know how to set up my variables into these names/function (i.e. don’t know the approriate coding syntax).
As an example;
the inputs are: M1 = [ i1 i2 i3 ………… i20], M2 = [ i1 i2 i3 ………….i20], K1 = [ i1 i2 i3 ………… i20], K2 = [ i1 i2 i3 ………….i20],
the relationship between theroretical values of M1, M2 and the K1 and K2 are:
M1T(i) = a1*K1(i) + a2*K1(i)*K2(i) + a3*K2(i) + a4*(K1(i))^2
M2T(i) = a2*K2(i) + a2*K1(i) + a5*(K2(i))^2 + a6*K1(i)*K2(i) optimization, minimization algorithm MATLAB Answers — New Questions
How to seamlessly combine the two inputs given to the prismatic joint
Hello, I am currently conducting research on the 6-degree-of-freedom motion control of a Stewart platform using Simulink. I am creating the movement of the top platform by applying force input to the prismatic joints of the Stewart platform.
The algorithm conditions are as follows:
20-second simulation
Raise the actuators to the neutral position of 3.52m with a heave motion until 10 seconds.
Control the actuators to implement 6-degree-of-freedom motion from 10 seconds to 20 seconds.
Currently, I have completed the process of raising the actuators to the neutral position of 3.52m in step 2. However, to ensure continuity between step 2 and step 3, I need the input from step 2 and the input from step 3. I have implemented the inputs for both steps, but I am having difficulty combining the two inputs at the 10-second mark. Specifically, the actuators should rise to 3.52m until 10 seconds, and another input should be applied until 20 seconds in a continuous manner. I do not know how to make this transition smooth and continuous.Hello, I am currently conducting research on the 6-degree-of-freedom motion control of a Stewart platform using Simulink. I am creating the movement of the top platform by applying force input to the prismatic joints of the Stewart platform.
The algorithm conditions are as follows:
20-second simulation
Raise the actuators to the neutral position of 3.52m with a heave motion until 10 seconds.
Control the actuators to implement 6-degree-of-freedom motion from 10 seconds to 20 seconds.
Currently, I have completed the process of raising the actuators to the neutral position of 3.52m in step 2. However, to ensure continuity between step 2 and step 3, I need the input from step 2 and the input from step 3. I have implemented the inputs for both steps, but I am having difficulty combining the two inputs at the 10-second mark. Specifically, the actuators should rise to 3.52m until 10 seconds, and another input should be applied until 20 seconds in a continuous manner. I do not know how to make this transition smooth and continuous. Hello, I am currently conducting research on the 6-degree-of-freedom motion control of a Stewart platform using Simulink. I am creating the movement of the top platform by applying force input to the prismatic joints of the Stewart platform.
The algorithm conditions are as follows:
20-second simulation
Raise the actuators to the neutral position of 3.52m with a heave motion until 10 seconds.
Control the actuators to implement 6-degree-of-freedom motion from 10 seconds to 20 seconds.
Currently, I have completed the process of raising the actuators to the neutral position of 3.52m in step 2. However, to ensure continuity between step 2 and step 3, I need the input from step 2 and the input from step 3. I have implemented the inputs for both steps, but I am having difficulty combining the two inputs at the 10-second mark. Specifically, the actuators should rise to 3.52m until 10 seconds, and another input should be applied until 20 seconds in a continuous manner. I do not know how to make this transition smooth and continuous. simulink MATLAB Answers — New Questions
function must return a column vector
Hi, i am trying to plot some graphs for my my theses but i keep on getting error message..
find attached the code.. please help
function Juve_Model
clc;
%close all
global NO
%initial condition
Initial1 = [100,30,10,30];
hold on
for i=1:2:10
Initial=Initial1*i;
[t,u]=ode45(@hcv4,0:0.5:90, Initial);
subplot(2,2,1)
grid on
hold on
%axis([0 1400 0 1]);
plot(t,u(:,1),’linewidth’,3);
xlabel(‘Time (days)’)
ylabel(‘L’)
%*********************************************
subplot(2,2,2)
grid on
hold on
plot(t,u(:,2),’linewidth’,3);
xlabel(‘Time (days)’)
ylabel(‘F_1’)
%********************************************
subplot(2,2,3)
grid on
hold on
plot(t,u(:,3),’linewidth’,3);
xlabel(‘Time (days)’)
ylabel(‘F_2’)
%*******************************************
subplot(2,2,4)
grid on
hold on
plot(t,u(:,4),’linewidth’,3);
xlabel(‘Time (days)’)
ylabel(‘M’)
end
NO
end
function dy=hcv4(t,y)
%y=(L, F_1,F_2,M)=(y(1),y(2),y(3),y(4))
global NO
alpha=15; beta=0.1; q=0.3; gamma =0.7;
%beta=0.15; q=0.35; gamma=0.75;
K=1000; mu_L=0.35; d=0.45; mu_F1=0.15; mu_M=0.15; mu_F2=0.5;
% Basic Offspring (Reproduction) Number
NO=alpha*gamma*beta*q/(mu_F2*(mu_F1+gamma)*(beta+mu_L+d));
%Ordinary differential equation
dy(1)=alpha*(1-y(1)/K)*y(3)-(beta+mu_L+d)*y(1);
dy(2)=beta*q*y(1)-(mu_F1+gamma)*y(2);
dy(3)=gamma*y(2)-mu_F2*y(3);
dy(4)=beta*(1-q)*y(1)-mu_M*y(4);
endHi, i am trying to plot some graphs for my my theses but i keep on getting error message..
find attached the code.. please help
function Juve_Model
clc;
%close all
global NO
%initial condition
Initial1 = [100,30,10,30];
hold on
for i=1:2:10
Initial=Initial1*i;
[t,u]=ode45(@hcv4,0:0.5:90, Initial);
subplot(2,2,1)
grid on
hold on
%axis([0 1400 0 1]);
plot(t,u(:,1),’linewidth’,3);
xlabel(‘Time (days)’)
ylabel(‘L’)
%*********************************************
subplot(2,2,2)
grid on
hold on
plot(t,u(:,2),’linewidth’,3);
xlabel(‘Time (days)’)
ylabel(‘F_1’)
%********************************************
subplot(2,2,3)
grid on
hold on
plot(t,u(:,3),’linewidth’,3);
xlabel(‘Time (days)’)
ylabel(‘F_2’)
%*******************************************
subplot(2,2,4)
grid on
hold on
plot(t,u(:,4),’linewidth’,3);
xlabel(‘Time (days)’)
ylabel(‘M’)
end
NO
end
function dy=hcv4(t,y)
%y=(L, F_1,F_2,M)=(y(1),y(2),y(3),y(4))
global NO
alpha=15; beta=0.1; q=0.3; gamma =0.7;
%beta=0.15; q=0.35; gamma=0.75;
K=1000; mu_L=0.35; d=0.45; mu_F1=0.15; mu_M=0.15; mu_F2=0.5;
% Basic Offspring (Reproduction) Number
NO=alpha*gamma*beta*q/(mu_F2*(mu_F1+gamma)*(beta+mu_L+d));
%Ordinary differential equation
dy(1)=alpha*(1-y(1)/K)*y(3)-(beta+mu_L+d)*y(1);
dy(2)=beta*q*y(1)-(mu_F1+gamma)*y(2);
dy(3)=gamma*y(2)-mu_F2*y(3);
dy(4)=beta*(1-q)*y(1)-mu_M*y(4);
end Hi, i am trying to plot some graphs for my my theses but i keep on getting error message..
find attached the code.. please help
function Juve_Model
clc;
%close all
global NO
%initial condition
Initial1 = [100,30,10,30];
hold on
for i=1:2:10
Initial=Initial1*i;
[t,u]=ode45(@hcv4,0:0.5:90, Initial);
subplot(2,2,1)
grid on
hold on
%axis([0 1400 0 1]);
plot(t,u(:,1),’linewidth’,3);
xlabel(‘Time (days)’)
ylabel(‘L’)
%*********************************************
subplot(2,2,2)
grid on
hold on
plot(t,u(:,2),’linewidth’,3);
xlabel(‘Time (days)’)
ylabel(‘F_1’)
%********************************************
subplot(2,2,3)
grid on
hold on
plot(t,u(:,3),’linewidth’,3);
xlabel(‘Time (days)’)
ylabel(‘F_2’)
%*******************************************
subplot(2,2,4)
grid on
hold on
plot(t,u(:,4),’linewidth’,3);
xlabel(‘Time (days)’)
ylabel(‘M’)
end
NO
end
function dy=hcv4(t,y)
%y=(L, F_1,F_2,M)=(y(1),y(2),y(3),y(4))
global NO
alpha=15; beta=0.1; q=0.3; gamma =0.7;
%beta=0.15; q=0.35; gamma=0.75;
K=1000; mu_L=0.35; d=0.45; mu_F1=0.15; mu_M=0.15; mu_F2=0.5;
% Basic Offspring (Reproduction) Number
NO=alpha*gamma*beta*q/(mu_F2*(mu_F1+gamma)*(beta+mu_L+d));
%Ordinary differential equation
dy(1)=alpha*(1-y(1)/K)*y(3)-(beta+mu_L+d)*y(1);
dy(2)=beta*q*y(1)-(mu_F1+gamma)*y(2);
dy(3)=gamma*y(2)-mu_F2*y(3);
dy(4)=beta*(1-q)*y(1)-mu_M*y(4);
end global stability MATLAB Answers — New Questions
GCC Error When Compiling S-Function
I am attempting to compile an S-Function using the "mex" command in MATLAB. However, I encounter the following errors during the compilation process: GCC error create process: no such file or directory.
Can anybody help me resolve the issue ?I am attempting to compile an S-Function using the "mex" command in MATLAB. However, I encounter the following errors during the compilation process: GCC error create process: no such file or directory.
Can anybody help me resolve the issue ? I am attempting to compile an S-Function using the "mex" command in MATLAB. However, I encounter the following errors during the compilation process: GCC error create process: no such file or directory.
Can anybody help me resolve the issue ? r2017b MATLAB Answers — New Questions