Month: July 2024
Customize “FileExplorer” to Open a Specific Folder
I want FileExplorer to automatically open at a specific location when launched, such as %HOMEDRIVE%%HOMEPATH%, whether it’s from the taskbar icon or by pressing Winkey-E. Previously, I had my user folders pinned in Quick Access, but I encountered an issue where they wouldn’t expand to show the content of the folder when clicked. While I created a new shortcut in the Start menu, my instinctive method of accessing FileExplorer is by pressing Winkey-E.
I want FileExplorer to automatically open at a specific location when launched, such as %HOMEDRIVE%%HOMEPATH%, whether it’s from the taskbar icon or by pressing Winkey-E. Previously, I had my user folders pinned in Quick Access, but I encountered an issue where they wouldn’t expand to show the content of the folder when clicked. While I created a new shortcut in the Start menu, my instinctive method of accessing FileExplorer is by pressing Winkey-E. Read More
Constant Hanging Issue in Windows 11
Greetings, everyone! As a software developer, I have encountered a significant issue with my system recently. While using Windows 11, it has become common to experience brief crashes, typically lasting about a second, such as when accessing the “control center” from the taskbar. However, unlike the typical behavior where the OS resumes functioning afterward, my system has started hanging during regular tasks.
Initially, my computer operated smoothly without such interruptions, except for the taskbar issue that was resolved by installing ExplorerPatcher. Presently, I encounter system hangs while performing routine activities, where my mouse cursor remains movable for a brief period before the entire system freezes. Curiously, any audio playing at the time continues uninterrupted as if nothing is wrong, further complicating the situation.
Notably, these hang-ups seem to occur most frequently during project build processes in Visual Studio. Interestingly, I have not faced this problem when indulging in graphically demanding games like GTA5, Valorant, or Dying Light 2 at ultra settings. To regain access to my system, a hard reset becomes necessary each time this issue arises.
Despite owning a high-end PC, the event viewer offers minimal insight except for the recurring report of “The previous shutdown was unexpected.” This ongoing challenge has prompted me to seek a reliable solution for uninterrupted computing experiences.
Greetings, everyone! As a software developer, I have encountered a significant issue with my system recently. While using Windows 11, it has become common to experience brief crashes, typically lasting about a second, such as when accessing the “control center” from the taskbar. However, unlike the typical behavior where the OS resumes functioning afterward, my system has started hanging during regular tasks. Initially, my computer operated smoothly without such interruptions, except for the taskbar issue that was resolved by installing ExplorerPatcher. Presently, I encounter system hangs while performing routine activities, where my mouse cursor remains movable for a brief period before the entire system freezes. Curiously, any audio playing at the time continues uninterrupted as if nothing is wrong, further complicating the situation. Notably, these hang-ups seem to occur most frequently during project build processes in Visual Studio. Interestingly, I have not faced this problem when indulging in graphically demanding games like GTA5, Valorant, or Dying Light 2 at ultra settings. To regain access to my system, a hard reset becomes necessary each time this issue arises. Despite owning a high-end PC, the event viewer offers minimal insight except for the recurring report of “The previous shutdown was unexpected.” This ongoing challenge has prompted me to seek a reliable solution for uninterrupted computing experiences. Read More
Reduce the inputs for the chi2gof function (follow-up question of: Using chi2gof to test two distributions)
This is a follow-up question of Using chi2gof to test two distributions.
@Allie had the following inputs, i.e. the binned observational data (x), the binned model data (y), and the bin edges (bins):
x= [41 22 11 10 9 5 2 3 2];
y= [38.052 24.2655 15.4665 9.8595 6.2895 4.011 2.562 1.6275 2.8665];
bins=[0:9:81];
and asked how to use "chi2gof to test if two distributions come from a common distribution (null hypothesis) or if they do not come from a common distribution (alternative hypothesis)".
The accepted answer comes from @Jeff Miller:
bins=[0:9:81];
xvals = bins(1:end-1)+4.5; % Here are some fake data values that belong in each bin.
xcounts= [41 22 11 10 9 5 2 3 2]; % These are the counts of the data values in each bin.
y= [38.052 24.2655 15.4665 9.8595 6.2895 4.011 2.562 1.6275 2.8665];
[h,p,stat]=chi2gof(xvals,’Edges’,bins,’Expected’,y,’Frequency’,xcounts,’EMin’,1)
However, by re-doing all the calculations, i.e.
% inputs
alpha = 0.05;
x= [41 22 11 10 9 5 2 3 2]; % <– observed data
y= [38.052 24.2655 15.4665 9.8595 6.2895 4.011 2.562 1.6275 2.8665]; % <– expected data
% Chi-square goodness-of-fit test
chi2 = sum(((x-y).^2)./y); % <– chi-square value
df = length(x)-1; % <– degrees of freedom
p = chi2cdf(chi2,df,’upper’); % <– p-value calculated from the chi-square distribution with "df" degrees of freedom
if p>alpha % <– accept or reject the null hypothesis, based on the p-value
h = 0; % <– disp(‘we fail to reject the null hypothesis’)
else
h = 1; % <– disp(‘we reject the null hypothesis’)
end
table([chi2; df; p; h],’RowNames’,{‘chi-square’,’df’,’p-value’,’h’},’VariableNames’,{‘Stats’})
I have realized that "xvals" and the "bins" are not necessary for the Chi-square goodness-of-fit test.
Then, is it possible to still use the chi2gof function, but just employing "x" and "y" (and "alpha") as the only inputs?This is a follow-up question of Using chi2gof to test two distributions.
@Allie had the following inputs, i.e. the binned observational data (x), the binned model data (y), and the bin edges (bins):
x= [41 22 11 10 9 5 2 3 2];
y= [38.052 24.2655 15.4665 9.8595 6.2895 4.011 2.562 1.6275 2.8665];
bins=[0:9:81];
and asked how to use "chi2gof to test if two distributions come from a common distribution (null hypothesis) or if they do not come from a common distribution (alternative hypothesis)".
The accepted answer comes from @Jeff Miller:
bins=[0:9:81];
xvals = bins(1:end-1)+4.5; % Here are some fake data values that belong in each bin.
xcounts= [41 22 11 10 9 5 2 3 2]; % These are the counts of the data values in each bin.
y= [38.052 24.2655 15.4665 9.8595 6.2895 4.011 2.562 1.6275 2.8665];
[h,p,stat]=chi2gof(xvals,’Edges’,bins,’Expected’,y,’Frequency’,xcounts,’EMin’,1)
However, by re-doing all the calculations, i.e.
% inputs
alpha = 0.05;
x= [41 22 11 10 9 5 2 3 2]; % <– observed data
y= [38.052 24.2655 15.4665 9.8595 6.2895 4.011 2.562 1.6275 2.8665]; % <– expected data
% Chi-square goodness-of-fit test
chi2 = sum(((x-y).^2)./y); % <– chi-square value
df = length(x)-1; % <– degrees of freedom
p = chi2cdf(chi2,df,’upper’); % <– p-value calculated from the chi-square distribution with "df" degrees of freedom
if p>alpha % <– accept or reject the null hypothesis, based on the p-value
h = 0; % <– disp(‘we fail to reject the null hypothesis’)
else
h = 1; % <– disp(‘we reject the null hypothesis’)
end
table([chi2; df; p; h],’RowNames’,{‘chi-square’,’df’,’p-value’,’h’},’VariableNames’,{‘Stats’})
I have realized that "xvals" and the "bins" are not necessary for the Chi-square goodness-of-fit test.
Then, is it possible to still use the chi2gof function, but just employing "x" and "y" (and "alpha") as the only inputs? This is a follow-up question of Using chi2gof to test two distributions.
@Allie had the following inputs, i.e. the binned observational data (x), the binned model data (y), and the bin edges (bins):
x= [41 22 11 10 9 5 2 3 2];
y= [38.052 24.2655 15.4665 9.8595 6.2895 4.011 2.562 1.6275 2.8665];
bins=[0:9:81];
and asked how to use "chi2gof to test if two distributions come from a common distribution (null hypothesis) or if they do not come from a common distribution (alternative hypothesis)".
The accepted answer comes from @Jeff Miller:
bins=[0:9:81];
xvals = bins(1:end-1)+4.5; % Here are some fake data values that belong in each bin.
xcounts= [41 22 11 10 9 5 2 3 2]; % These are the counts of the data values in each bin.
y= [38.052 24.2655 15.4665 9.8595 6.2895 4.011 2.562 1.6275 2.8665];
[h,p,stat]=chi2gof(xvals,’Edges’,bins,’Expected’,y,’Frequency’,xcounts,’EMin’,1)
However, by re-doing all the calculations, i.e.
% inputs
alpha = 0.05;
x= [41 22 11 10 9 5 2 3 2]; % <– observed data
y= [38.052 24.2655 15.4665 9.8595 6.2895 4.011 2.562 1.6275 2.8665]; % <– expected data
% Chi-square goodness-of-fit test
chi2 = sum(((x-y).^2)./y); % <– chi-square value
df = length(x)-1; % <– degrees of freedom
p = chi2cdf(chi2,df,’upper’); % <– p-value calculated from the chi-square distribution with "df" degrees of freedom
if p>alpha % <– accept or reject the null hypothesis, based on the p-value
h = 0; % <– disp(‘we fail to reject the null hypothesis’)
else
h = 1; % <– disp(‘we reject the null hypothesis’)
end
table([chi2; df; p; h],’RowNames’,{‘chi-square’,’df’,’p-value’,’h’},’VariableNames’,{‘Stats’})
I have realized that "xvals" and the "bins" are not necessary for the Chi-square goodness-of-fit test.
Then, is it possible to still use the chi2gof function, but just employing "x" and "y" (and "alpha") as the only inputs? chi2gof, distributions, chi-square, chi-square test MATLAB Answers — New Questions
How to setup a multi-agent DDPG
Hi,
I am trying to simulate a number of agents that collaboratively doing mapping. I designed the actor critic networks, but I have a problem that how I can write a code for gridworld file inside my simulink. Is there any related example?Hi,
I am trying to simulate a number of agents that collaboratively doing mapping. I designed the actor critic networks, but I have a problem that how I can write a code for gridworld file inside my simulink. Is there any related example? Hi,
I am trying to simulate a number of agents that collaboratively doing mapping. I designed the actor critic networks, but I have a problem that how I can write a code for gridworld file inside my simulink. Is there any related example? ddpg MATLAB Answers — New Questions
Can you convert DatetimeRuler to DurationRuler?
I have a series of utilities that generate figures like:
fh = figure;
ax = axes(fh);
plot(ax, datetime("now")+minutes(1:5), 1:5, "–x");
Which use datetime objects for the XData (and therefore have a DatetimeRuler for the x-axis) because it makes it easier to find reference data in the future.
However, for presentations, I generally want plots that use a DurationRuler for the sake of clarity. Is there any way to update ax.XAxis (or maybe even all of the ax.Children entries) such that I could have figures that look like they were generated like this instead:
fh = figure;
ax = axes(fh);
plot(ax, minutes(1:5), 1:5, "–x");
I could update all the plotting utilities to optionally use Duration objects from some reference but this would effect several utilities and it would be more convenient to just pass an axis or figure handle to some function that could do the conversion after the figure exists.I have a series of utilities that generate figures like:
fh = figure;
ax = axes(fh);
plot(ax, datetime("now")+minutes(1:5), 1:5, "–x");
Which use datetime objects for the XData (and therefore have a DatetimeRuler for the x-axis) because it makes it easier to find reference data in the future.
However, for presentations, I generally want plots that use a DurationRuler for the sake of clarity. Is there any way to update ax.XAxis (or maybe even all of the ax.Children entries) such that I could have figures that look like they were generated like this instead:
fh = figure;
ax = axes(fh);
plot(ax, minutes(1:5), 1:5, "–x");
I could update all the plotting utilities to optionally use Duration objects from some reference but this would effect several utilities and it would be more convenient to just pass an axis or figure handle to some function that could do the conversion after the figure exists. I have a series of utilities that generate figures like:
fh = figure;
ax = axes(fh);
plot(ax, datetime("now")+minutes(1:5), 1:5, "–x");
Which use datetime objects for the XData (and therefore have a DatetimeRuler for the x-axis) because it makes it easier to find reference data in the future.
However, for presentations, I generally want plots that use a DurationRuler for the sake of clarity. Is there any way to update ax.XAxis (or maybe even all of the ax.Children entries) such that I could have figures that look like they were generated like this instead:
fh = figure;
ax = axes(fh);
plot(ax, minutes(1:5), 1:5, "–x");
I could update all the plotting utilities to optionally use Duration objects from some reference but this would effect several utilities and it would be more convenient to just pass an axis or figure handle to some function that could do the conversion after the figure exists. plotting, axes, datetime MATLAB Answers — New Questions
Event transfer from Onprem to Cloud Connectivity
We have a On-Premises application (with Linux OS) that generates an multiple type of events and write them as files into local file system, with more than 50k events per day. The On-Premises infra have connectivity to Azure but application doesn’t have it. These event needs to be published to cloud based application, and we also need to audit every events, there will be high impact even if single event is lost.
The existing documentation is not sufficient to arrive at a solution, Is there any recommended options.
We have a On-Premises application (with Linux OS) that generates an multiple type of events and write them as files into local file system, with more than 50k events per day. The On-Premises infra have connectivity to Azure but application doesn’t have it. These event needs to be published to cloud based application, and we also need to audit every events, there will be high impact even if single event is lost.The existing documentation is not sufficient to arrive at a solution, Is there any recommended options. Read More
Comparing two columns with comma separated string values (match)
Hi,
I currently have two columns of reference data. Each cell contains comma separated values.
My aim is to find a match between any of the patent numbers in column A within the corresponding row in column B. E.g. in row 2, there is a match between value in column 1 (CN…385A) and column 2).
Ideally the output in column C would be “yes” or “match”.
Ideally want to keep cells formatted as they are, with delimiters between patent numbers.
many thanks
Hi, I currently have two columns of reference data. Each cell contains comma separated values. My aim is to find a match between any of the patent numbers in column A within the corresponding row in column B. E.g. in row 2, there is a match between value in column 1 (CN…385A) and column 2).Ideally the output in column C would be “yes” or “match”. Ideally want to keep cells formatted as they are, with delimiters between patent numbers. many thanks Read More
license function can’t list Computer Vision Toolbox™?
When I use license function to check if there is already a Computer Vision Toolbox™ in the MATLAB environment, I don’t know how to get what the function input parameter `feature` corresponds to the name of this toolbox? I have tried the following methods and they all return a status of 0, but I am sure that Computer Vision Toolbox is installed and working, how do I find out what the name of the `feature` corresponds to?
license("test","computer_vision_toolbox")
license("test","vision_toolbox")
license("checkout","computer_vision_toolbox")
——————————————————————————————————-
Another related question is: How can I check if a specific toolbox is installed in the current environment using MATLAB code?
As far as I know, the ver function can return all installed toolboxes status and then you can search for the name, but the official documentation no longer recommends using the ver function since R2023b. Instead, it suggests using the matlabRelease function, but this function only returns the version number and does not provide the installation status of the toolboxes.When I use license function to check if there is already a Computer Vision Toolbox™ in the MATLAB environment, I don’t know how to get what the function input parameter `feature` corresponds to the name of this toolbox? I have tried the following methods and they all return a status of 0, but I am sure that Computer Vision Toolbox is installed and working, how do I find out what the name of the `feature` corresponds to?
license("test","computer_vision_toolbox")
license("test","vision_toolbox")
license("checkout","computer_vision_toolbox")
——————————————————————————————————-
Another related question is: How can I check if a specific toolbox is installed in the current environment using MATLAB code?
As far as I know, the ver function can return all installed toolboxes status and then you can search for the name, but the official documentation no longer recommends using the ver function since R2023b. Instead, it suggests using the matlabRelease function, but this function only returns the version number and does not provide the installation status of the toolboxes. When I use license function to check if there is already a Computer Vision Toolbox™ in the MATLAB environment, I don’t know how to get what the function input parameter `feature` corresponds to the name of this toolbox? I have tried the following methods and they all return a status of 0, but I am sure that Computer Vision Toolbox is installed and working, how do I find out what the name of the `feature` corresponds to?
license("test","computer_vision_toolbox")
license("test","vision_toolbox")
license("checkout","computer_vision_toolbox")
——————————————————————————————————-
Another related question is: How can I check if a specific toolbox is installed in the current environment using MATLAB code?
As far as I know, the ver function can return all installed toolboxes status and then you can search for the name, but the official documentation no longer recommends using the ver function since R2023b. Instead, it suggests using the matlabRelease function, but this function only returns the version number and does not provide the installation status of the toolboxes. computer vision, installation MATLAB Answers — New Questions
Using OPC UA read and write blocks within a Simu,ink Model
I’m using OPC UA Read and Write blocks within a Simulink model. I want to create a simulation app (by selecting ‘Simulation App…’ from the ‘Save’ dropdown menu. However, the creation fails because the OPC UA classes do not support code generation.
Are there any plans to make them compileable? Alternatively, is there a workaround? I’ve tried to create bespoke read and write OPC UA blocks, but run into the same problem.
Thanks,I’m using OPC UA Read and Write blocks within a Simulink model. I want to create a simulation app (by selecting ‘Simulation App…’ from the ‘Save’ dropdown menu. However, the creation fails because the OPC UA classes do not support code generation.
Are there any plans to make them compileable? Alternatively, is there a workaround? I’ve tried to create bespoke read and write OPC UA blocks, but run into the same problem.
Thanks, I’m using OPC UA Read and Write blocks within a Simulink model. I want to create a simulation app (by selecting ‘Simulation App…’ from the ‘Save’ dropdown menu. However, the creation fails because the OPC UA classes do not support code generation.
Are there any plans to make them compileable? Alternatively, is there a workaround? I’ve tried to create bespoke read and write OPC UA blocks, but run into the same problem.
Thanks, opc ua, code generation MATLAB Answers — New Questions
I’m having trouble solving a system of nonlinear equations with the fmincon function.
I want to solve a system of equations containing two non-linear equations, one of which is Psh_newhv == Pse_newhv,the other is Qs_newhv==0, but solving it with the fmincon function doesn’t achieve the first constraint, how can I solve this problem?
% Given constants
V_s = 10*1e3/sqrt(3);
n_t = 25*sqrt(3);
V_r = 400/sqrt(3);
theta_r = pi/12;
Srate = 100*1e3/3;
Zbase = (V_r)^2/Srate;
X_r = 0.4*Zbase;
X_t = 400^2/(300*1e3)*4/100;
rho = 0:2*pi/72:2*pi;
V_se = 0.2*V_r;
V_se_newhv = 0.2*V_s;
Z_r = 1i * X_r;
% Initial guess
x0 = [0 0];
% Options for fmincon
options = optimoptions(‘fmincon’, ‘Algorithm’, ‘interior-point’, ‘Display’, ‘off’,’ConstraintTolerance’,1e-6);
% Constraints
lb = [];
ub = [];
% Solve for each rho
for m = 1:73
% Define the nonlinear constraint function
fun_newhv = @(x_newhv) myfun_newhv(x_newhv, rho(m));
% Use fmincon to solve the problem
[x_newhv, fval_newhv, exitflag_newhv(m), output_newhv] = fmincon(@(x_newhv) 0, x0, [], [], [], [], lb, ub, fun_newhv, options);
% Extract solutions
gamma_newhv(m) = x_newhv(1);
I_sh_newhv(m) = x_newhv(2);
I_r_newhv(m)=1/(Z_r+j*X_t)*(sqrt(3)*(V_s+V_se_newhv*exp(j*rho(m)))*exp(j*pi/6)/n_t-V_r*exp(j*theta_r));
V_tap_newhv=0.5*(V_s+V_se_newhv*exp(j*rho(m)))*exp(j*-pi/3);
Pr_newhv(m)=real(V_r*exp(j*theta_r)*conj( I_r_newhv(m)));
Qr_newhv(m)=imag(V_r*exp(j*theta_r)*conj( I_r_newhv(m)));
I_s_newhv(m)=0.5*I_sh_newhv(m)*exp(j*gamma_newhv(m))*exp(j*pi/3)+sqrt(3)/n_t* I_r_newhv(m)*exp(j*-pi/6);
Ps_newhv(m)=real(V_s*conj(I_s_newhv(m)));
Qs_newhv(m)=imag(V_s*conj(I_s_newhv(m)));
Psh_newhv(m)=real(V_tap_newhv*conj(I_sh_newhv(m)*exp(j*gamma_newhv(m))));
Qsh_newhv(m)=imag(V_tap_newhv*conj(I_sh_newhv(m)*exp(j*gamma_newhv(m))));
Ssh_newhv(m) = sqrt(Psh_newhv(m)^2 + Qsh_newhv(m)^2);
Pse_newhv(m)=real(V_se_newhv*exp(j*rho(m))*conj(I_sh_newhv(m)));
Qse_newhv(m)=imag(V_se_newhv*exp(j*rho(m))*conj(I_sh_newhv(m)));
Sse_newhv(m) = sqrt(Pse_newhv(m)^2 + Qse_newhv(m)^2);
end
polarplot( (Psh_newhv – Pse_newhv)/Srate,LineWidth=2)
hold on
polarplot( Qs_newhv/Srate,LineWidth=2)
% Nonlinear constraint function
function [c, ceq] = myfun_newhv(x_newhv, rho)
V_s = 10*1e3/sqrt(3);
n_t = 25*sqrt(3);
V_r = 400/sqrt(3);
theta_r = pi/12;
Srate = 100*1e3/3;
Zbase = (V_r)^2/Srate;
X_r = 0.4*Zbase;
X_t = 400^2/(300*1e3)*4/100;
V_se_newhv = 0.2*V_s;
Z_r = 1i * X_r;
% Extract variables
gamma_newhv = x_newhv(1);
I_sh_newhv = x_newhv(2);
% Compute intermediate quantities
I_r_newhv=1/(Z_r+j*X_t)*(sqrt(3)*(V_s+V_se_newhv*exp(j*rho))*exp(j*pi/6)/n_t-V_r*exp(j*theta_r));
I_s_newhv=0.5*I_sh_newhv*exp(j*gamma_newhv)*exp(j*pi/3)+sqrt(3)/n_t* I_r_newhv*exp(j*-pi/6);
Qs_newhv=imag(V_s*conj(I_s_newhv));
V_tap_newhv=0.5*(V_s+V_se_newhv*exp(j*rho))*exp(j*-pi/3);
Psh_newhv=real(V_tap_newhv*conj(I_sh_newhv*exp(j*gamma_newhv)));
Pse_newhv=real(V_se_newhv*exp(j*rho)*conj(I_s_newhv));
% Constraints
% Nonlinear equality constraints
ceq = [ Psh_newhv – Pse_newhv;Qs_newhv];
c = [];
endI want to solve a system of equations containing two non-linear equations, one of which is Psh_newhv == Pse_newhv,the other is Qs_newhv==0, but solving it with the fmincon function doesn’t achieve the first constraint, how can I solve this problem?
% Given constants
V_s = 10*1e3/sqrt(3);
n_t = 25*sqrt(3);
V_r = 400/sqrt(3);
theta_r = pi/12;
Srate = 100*1e3/3;
Zbase = (V_r)^2/Srate;
X_r = 0.4*Zbase;
X_t = 400^2/(300*1e3)*4/100;
rho = 0:2*pi/72:2*pi;
V_se = 0.2*V_r;
V_se_newhv = 0.2*V_s;
Z_r = 1i * X_r;
% Initial guess
x0 = [0 0];
% Options for fmincon
options = optimoptions(‘fmincon’, ‘Algorithm’, ‘interior-point’, ‘Display’, ‘off’,’ConstraintTolerance’,1e-6);
% Constraints
lb = [];
ub = [];
% Solve for each rho
for m = 1:73
% Define the nonlinear constraint function
fun_newhv = @(x_newhv) myfun_newhv(x_newhv, rho(m));
% Use fmincon to solve the problem
[x_newhv, fval_newhv, exitflag_newhv(m), output_newhv] = fmincon(@(x_newhv) 0, x0, [], [], [], [], lb, ub, fun_newhv, options);
% Extract solutions
gamma_newhv(m) = x_newhv(1);
I_sh_newhv(m) = x_newhv(2);
I_r_newhv(m)=1/(Z_r+j*X_t)*(sqrt(3)*(V_s+V_se_newhv*exp(j*rho(m)))*exp(j*pi/6)/n_t-V_r*exp(j*theta_r));
V_tap_newhv=0.5*(V_s+V_se_newhv*exp(j*rho(m)))*exp(j*-pi/3);
Pr_newhv(m)=real(V_r*exp(j*theta_r)*conj( I_r_newhv(m)));
Qr_newhv(m)=imag(V_r*exp(j*theta_r)*conj( I_r_newhv(m)));
I_s_newhv(m)=0.5*I_sh_newhv(m)*exp(j*gamma_newhv(m))*exp(j*pi/3)+sqrt(3)/n_t* I_r_newhv(m)*exp(j*-pi/6);
Ps_newhv(m)=real(V_s*conj(I_s_newhv(m)));
Qs_newhv(m)=imag(V_s*conj(I_s_newhv(m)));
Psh_newhv(m)=real(V_tap_newhv*conj(I_sh_newhv(m)*exp(j*gamma_newhv(m))));
Qsh_newhv(m)=imag(V_tap_newhv*conj(I_sh_newhv(m)*exp(j*gamma_newhv(m))));
Ssh_newhv(m) = sqrt(Psh_newhv(m)^2 + Qsh_newhv(m)^2);
Pse_newhv(m)=real(V_se_newhv*exp(j*rho(m))*conj(I_sh_newhv(m)));
Qse_newhv(m)=imag(V_se_newhv*exp(j*rho(m))*conj(I_sh_newhv(m)));
Sse_newhv(m) = sqrt(Pse_newhv(m)^2 + Qse_newhv(m)^2);
end
polarplot( (Psh_newhv – Pse_newhv)/Srate,LineWidth=2)
hold on
polarplot( Qs_newhv/Srate,LineWidth=2)
% Nonlinear constraint function
function [c, ceq] = myfun_newhv(x_newhv, rho)
V_s = 10*1e3/sqrt(3);
n_t = 25*sqrt(3);
V_r = 400/sqrt(3);
theta_r = pi/12;
Srate = 100*1e3/3;
Zbase = (V_r)^2/Srate;
X_r = 0.4*Zbase;
X_t = 400^2/(300*1e3)*4/100;
V_se_newhv = 0.2*V_s;
Z_r = 1i * X_r;
% Extract variables
gamma_newhv = x_newhv(1);
I_sh_newhv = x_newhv(2);
% Compute intermediate quantities
I_r_newhv=1/(Z_r+j*X_t)*(sqrt(3)*(V_s+V_se_newhv*exp(j*rho))*exp(j*pi/6)/n_t-V_r*exp(j*theta_r));
I_s_newhv=0.5*I_sh_newhv*exp(j*gamma_newhv)*exp(j*pi/3)+sqrt(3)/n_t* I_r_newhv*exp(j*-pi/6);
Qs_newhv=imag(V_s*conj(I_s_newhv));
V_tap_newhv=0.5*(V_s+V_se_newhv*exp(j*rho))*exp(j*-pi/3);
Psh_newhv=real(V_tap_newhv*conj(I_sh_newhv*exp(j*gamma_newhv)));
Pse_newhv=real(V_se_newhv*exp(j*rho)*conj(I_s_newhv));
% Constraints
% Nonlinear equality constraints
ceq = [ Psh_newhv – Pse_newhv;Qs_newhv];
c = [];
end I want to solve a system of equations containing two non-linear equations, one of which is Psh_newhv == Pse_newhv,the other is Qs_newhv==0, but solving it with the fmincon function doesn’t achieve the first constraint, how can I solve this problem?
% Given constants
V_s = 10*1e3/sqrt(3);
n_t = 25*sqrt(3);
V_r = 400/sqrt(3);
theta_r = pi/12;
Srate = 100*1e3/3;
Zbase = (V_r)^2/Srate;
X_r = 0.4*Zbase;
X_t = 400^2/(300*1e3)*4/100;
rho = 0:2*pi/72:2*pi;
V_se = 0.2*V_r;
V_se_newhv = 0.2*V_s;
Z_r = 1i * X_r;
% Initial guess
x0 = [0 0];
% Options for fmincon
options = optimoptions(‘fmincon’, ‘Algorithm’, ‘interior-point’, ‘Display’, ‘off’,’ConstraintTolerance’,1e-6);
% Constraints
lb = [];
ub = [];
% Solve for each rho
for m = 1:73
% Define the nonlinear constraint function
fun_newhv = @(x_newhv) myfun_newhv(x_newhv, rho(m));
% Use fmincon to solve the problem
[x_newhv, fval_newhv, exitflag_newhv(m), output_newhv] = fmincon(@(x_newhv) 0, x0, [], [], [], [], lb, ub, fun_newhv, options);
% Extract solutions
gamma_newhv(m) = x_newhv(1);
I_sh_newhv(m) = x_newhv(2);
I_r_newhv(m)=1/(Z_r+j*X_t)*(sqrt(3)*(V_s+V_se_newhv*exp(j*rho(m)))*exp(j*pi/6)/n_t-V_r*exp(j*theta_r));
V_tap_newhv=0.5*(V_s+V_se_newhv*exp(j*rho(m)))*exp(j*-pi/3);
Pr_newhv(m)=real(V_r*exp(j*theta_r)*conj( I_r_newhv(m)));
Qr_newhv(m)=imag(V_r*exp(j*theta_r)*conj( I_r_newhv(m)));
I_s_newhv(m)=0.5*I_sh_newhv(m)*exp(j*gamma_newhv(m))*exp(j*pi/3)+sqrt(3)/n_t* I_r_newhv(m)*exp(j*-pi/6);
Ps_newhv(m)=real(V_s*conj(I_s_newhv(m)));
Qs_newhv(m)=imag(V_s*conj(I_s_newhv(m)));
Psh_newhv(m)=real(V_tap_newhv*conj(I_sh_newhv(m)*exp(j*gamma_newhv(m))));
Qsh_newhv(m)=imag(V_tap_newhv*conj(I_sh_newhv(m)*exp(j*gamma_newhv(m))));
Ssh_newhv(m) = sqrt(Psh_newhv(m)^2 + Qsh_newhv(m)^2);
Pse_newhv(m)=real(V_se_newhv*exp(j*rho(m))*conj(I_sh_newhv(m)));
Qse_newhv(m)=imag(V_se_newhv*exp(j*rho(m))*conj(I_sh_newhv(m)));
Sse_newhv(m) = sqrt(Pse_newhv(m)^2 + Qse_newhv(m)^2);
end
polarplot( (Psh_newhv – Pse_newhv)/Srate,LineWidth=2)
hold on
polarplot( Qs_newhv/Srate,LineWidth=2)
% Nonlinear constraint function
function [c, ceq] = myfun_newhv(x_newhv, rho)
V_s = 10*1e3/sqrt(3);
n_t = 25*sqrt(3);
V_r = 400/sqrt(3);
theta_r = pi/12;
Srate = 100*1e3/3;
Zbase = (V_r)^2/Srate;
X_r = 0.4*Zbase;
X_t = 400^2/(300*1e3)*4/100;
V_se_newhv = 0.2*V_s;
Z_r = 1i * X_r;
% Extract variables
gamma_newhv = x_newhv(1);
I_sh_newhv = x_newhv(2);
% Compute intermediate quantities
I_r_newhv=1/(Z_r+j*X_t)*(sqrt(3)*(V_s+V_se_newhv*exp(j*rho))*exp(j*pi/6)/n_t-V_r*exp(j*theta_r));
I_s_newhv=0.5*I_sh_newhv*exp(j*gamma_newhv)*exp(j*pi/3)+sqrt(3)/n_t* I_r_newhv*exp(j*-pi/6);
Qs_newhv=imag(V_s*conj(I_s_newhv));
V_tap_newhv=0.5*(V_s+V_se_newhv*exp(j*rho))*exp(j*-pi/3);
Psh_newhv=real(V_tap_newhv*conj(I_sh_newhv*exp(j*gamma_newhv)));
Pse_newhv=real(V_se_newhv*exp(j*rho)*conj(I_s_newhv));
% Constraints
% Nonlinear equality constraints
ceq = [ Psh_newhv – Pse_newhv;Qs_newhv];
c = [];
end fmincon, nonlinear equation MATLAB Answers — New Questions
Changes in Predicted values after training
Hello Friends,
I need some help as regards predicted values from an LSTM neural netwrok that I designed. See the attached picture of the main code for the LSTM.
After training , the predicted values are always different from the previous simulation.
In the training options, I tried to set the BiasInitializer to zeros and the WeightsInitializer as well to ones but still the changes in predicted values always occur.
I will be glad if someone can guide me on this point.Hello Friends,
I need some help as regards predicted values from an LSTM neural netwrok that I designed. See the attached picture of the main code for the LSTM.
After training , the predicted values are always different from the previous simulation.
In the training options, I tried to set the BiasInitializer to zeros and the WeightsInitializer as well to ones but still the changes in predicted values always occur.
I will be glad if someone can guide me on this point. Hello Friends,
I need some help as regards predicted values from an LSTM neural netwrok that I designed. See the attached picture of the main code for the LSTM.
After training , the predicted values are always different from the previous simulation.
In the training options, I tried to set the BiasInitializer to zeros and the WeightsInitializer as well to ones but still the changes in predicted values always occur.
I will be glad if someone can guide me on this point. lstm, predict, training option MATLAB Answers — New Questions
Extended kalman filter jacobian function
I am trying to code my extended Kalman filter on a system and I know the function of the jacobian of the nonlinear output function. I read the documentation and look at the MeasurementJacobianFcn example, but I would need to pass to the function some parameters, is this possible?I am trying to code my extended Kalman filter on a system and I know the function of the jacobian of the nonlinear output function. I read the documentation and look at the MeasurementJacobianFcn example, but I would need to pass to the function some parameters, is this possible? I am trying to code my extended Kalman filter on a system and I know the function of the jacobian of the nonlinear output function. I read the documentation and look at the MeasurementJacobianFcn example, but I would need to pass to the function some parameters, is this possible? extended kalman filter, jacobian MATLAB Answers — New Questions
Issue with adding a folder on external drive as onedrive
Dear All,
I’ve been using OneDrive to back up my data, with the OneDrive folder located on my external SSD. However, after reinstalling OneDrive, it no longer allows me to select a folder on the external SSD. Does anyone know if OneDrive has discontinued this feature or if there’s another way to achieve this?
Thank you!
Dear All, I’ve been using OneDrive to back up my data, with the OneDrive folder located on my external SSD. However, after reinstalling OneDrive, it no longer allows me to select a folder on the external SSD. Does anyone know if OneDrive has discontinued this feature or if there’s another way to achieve this? Thank you! Read More
which MATLAB version is suitable for modelling and simulation of this topic “SENSORLESS SPEED TRACKING OF AN INDUCTION MOTOR DRIVE BASED ON
which MATLAB version is suitable for modelling and simulation of this topic "SENSORLESS SPEED TRACKING OF AN INDUCTION MOTOR DRIVE BASED ON IMPROVED X-MRAS SPEED ESTIMATORwhich MATLAB version is suitable for modelling and simulation of this topic "SENSORLESS SPEED TRACKING OF AN INDUCTION MOTOR DRIVE BASED ON IMPROVED X-MRAS SPEED ESTIMATOR which MATLAB version is suitable for modelling and simulation of this topic "SENSORLESS SPEED TRACKING OF AN INDUCTION MOTOR DRIVE BASED ON IMPROVED X-MRAS SPEED ESTIMATOR x-mras, sensorless, control, induction motor drive MATLAB Answers — New Questions
Problem with time series analysis function using detrended fluctuation analysis
Hi,
this is quite a specialized question.
I am trying to analyze a time series (standard matrix) using detrended fluctuation analysis. The script/function I am using is dfaedit (see attachment). The problem I am facing is that the results come out negative even though the results are only meant to be positive between 0-2. Hence there must be an issue with the calculation but I can not identify what it is.
Does anyone have an idea?Hi,
this is quite a specialized question.
I am trying to analyze a time series (standard matrix) using detrended fluctuation analysis. The script/function I am using is dfaedit (see attachment). The problem I am facing is that the results come out negative even though the results are only meant to be positive between 0-2. Hence there must be an issue with the calculation but I can not identify what it is.
Does anyone have an idea? Hi,
this is quite a specialized question.
I am trying to analyze a time series (standard matrix) using detrended fluctuation analysis. The script/function I am using is dfaedit (see attachment). The problem I am facing is that the results come out negative even though the results are only meant to be positive between 0-2. Hence there must be an issue with the calculation but I can not identify what it is.
Does anyone have an idea? dfa, detrended fluctuation analysis, time series MATLAB Answers — New Questions
Simulation – number of samples
MATLAB Helpcenter states:
When analyzing your FIS, you can configure the resolution of the output variable universe of discourse. To do so, set the Number of Samples parameter.
Is there a preset (optimum) value and how is this determined?MATLAB Helpcenter states:
When analyzing your FIS, you can configure the resolution of the output variable universe of discourse. To do so, set the Number of Samples parameter.
Is there a preset (optimum) value and how is this determined? MATLAB Helpcenter states:
When analyzing your FIS, you can configure the resolution of the output variable universe of discourse. To do so, set the Number of Samples parameter.
Is there a preset (optimum) value and how is this determined? fuzzy logic designer, simulation, system validation MATLAB Answers — New Questions
How to calculate Total Harmonic Distortion (THD) by using matlab code from csv file
Hello everyone,
I have .csv exported from oscilloscope and I do not know how to calculate the THD (in percentage) from this file. The fundamental frequency is 60 Hz, and the file is about sinusoidal current waveform. Thank you so much for your help.Hello everyone,
I have .csv exported from oscilloscope and I do not know how to calculate the THD (in percentage) from this file. The fundamental frequency is 60 Hz, and the file is about sinusoidal current waveform. Thank you so much for your help. Hello everyone,
I have .csv exported from oscilloscope and I do not know how to calculate the THD (in percentage) from this file. The fundamental frequency is 60 Hz, and the file is about sinusoidal current waveform. Thank you so much for your help. fft, thd MATLAB Answers — New Questions
Why do I get the error “An error occurred while attempting to shut down MATLAB.”?
When trying to shut down MATLAB so I can update it, I get the following error:
An error occurred while attempting to shut down MATLAB. For help, see this MATLAB Answer.
Why am I receiving this error?When trying to shut down MATLAB so I can update it, I get the following error:
An error occurred while attempting to shut down MATLAB. For help, see this MATLAB Answer.
Why am I receiving this error? When trying to shut down MATLAB so I can update it, I get the following error:
An error occurred while attempting to shut down MATLAB. For help, see this MATLAB Answer.
Why am I receiving this error? MATLAB Answers — New Questions
Why does OCR separate Text into Words?
Hi all,
I am trying to retrieve specific text from scanned documents reporting tables of numbers. Since the table can change in the amount of column, I use the following approach:
1 – detection of the units of measure through OCR function,
2 – from the units I need (for example, kg/kW.h), calculation of a proper region of interest where OCR function is used to retrieve the needed numbers
This works rather fine but I do not obtain a consistent behaviour of OCR function. In particular, some cases, all the units are well separated into words by OCR function while in others they are grouped together in a single word. In the code below working with the attached data sample, you can see the issue. In particular, the 16th element of txt1.Words reports the units ‘(kg/kW.h)(kW.h/)’ rather than having two Words (one for ‘(kg/kW.h)’ and the other for ‘(kW.h/)’) with their own WordBoundingBoxes. I do not understand why in some case, the units are in the same Word and in other they are bounded together in a single Word. Is it possible to control the generation process of Words in OCR function?
clear all
load(‘test.mat’)
figure
imshow(I)
roi=[250.5 526 1300 142];
Iocr=insertShape(I,’rectangle’,roi,’ShapeColor’,’blue’);
hold on
imshow(Iocr)
txt1=ocr(I,roi,CharacterSet=".()kWrpmlhgh/");%,LayoutAnalysis=’word’);
UnitString=regexp(txt1.Words,'(?<=()[w./]*(?=))’,’match’);
UnitString(cellfun(@isempty,UnitString))=[];
UnitBox=txt1.WordBoundingBoxes(not(cellfun(@isempty,UnitString)),:);Hi all,
I am trying to retrieve specific text from scanned documents reporting tables of numbers. Since the table can change in the amount of column, I use the following approach:
1 – detection of the units of measure through OCR function,
2 – from the units I need (for example, kg/kW.h), calculation of a proper region of interest where OCR function is used to retrieve the needed numbers
This works rather fine but I do not obtain a consistent behaviour of OCR function. In particular, some cases, all the units are well separated into words by OCR function while in others they are grouped together in a single word. In the code below working with the attached data sample, you can see the issue. In particular, the 16th element of txt1.Words reports the units ‘(kg/kW.h)(kW.h/)’ rather than having two Words (one for ‘(kg/kW.h)’ and the other for ‘(kW.h/)’) with their own WordBoundingBoxes. I do not understand why in some case, the units are in the same Word and in other they are bounded together in a single Word. Is it possible to control the generation process of Words in OCR function?
clear all
load(‘test.mat’)
figure
imshow(I)
roi=[250.5 526 1300 142];
Iocr=insertShape(I,’rectangle’,roi,’ShapeColor’,’blue’);
hold on
imshow(Iocr)
txt1=ocr(I,roi,CharacterSet=".()kWrpmlhgh/");%,LayoutAnalysis=’word’);
UnitString=regexp(txt1.Words,'(?<=()[w./]*(?=))’,’match’);
UnitString(cellfun(@isempty,UnitString))=[];
UnitBox=txt1.WordBoundingBoxes(not(cellfun(@isempty,UnitString)),:); Hi all,
I am trying to retrieve specific text from scanned documents reporting tables of numbers. Since the table can change in the amount of column, I use the following approach:
1 – detection of the units of measure through OCR function,
2 – from the units I need (for example, kg/kW.h), calculation of a proper region of interest where OCR function is used to retrieve the needed numbers
This works rather fine but I do not obtain a consistent behaviour of OCR function. In particular, some cases, all the units are well separated into words by OCR function while in others they are grouped together in a single word. In the code below working with the attached data sample, you can see the issue. In particular, the 16th element of txt1.Words reports the units ‘(kg/kW.h)(kW.h/)’ rather than having two Words (one for ‘(kg/kW.h)’ and the other for ‘(kW.h/)’) with their own WordBoundingBoxes. I do not understand why in some case, the units are in the same Word and in other they are bounded together in a single Word. Is it possible to control the generation process of Words in OCR function?
clear all
load(‘test.mat’)
figure
imshow(I)
roi=[250.5 526 1300 142];
Iocr=insertShape(I,’rectangle’,roi,’ShapeColor’,’blue’);
hold on
imshow(Iocr)
txt1=ocr(I,roi,CharacterSet=".()kWrpmlhgh/");%,LayoutAnalysis=’word’);
UnitString=regexp(txt1.Words,'(?<=()[w./]*(?=))’,’match’);
UnitString(cellfun(@isempty,UnitString))=[];
UnitBox=txt1.WordBoundingBoxes(not(cellfun(@isempty,UnitString)),:); ocr MATLAB Answers — New Questions
MS Project allocation of resources
Hi,
When using ms project, is there any way I can have a maximum work time for a people resource.
My issue is this:
I am planning a diving job using welders. We have 6 welders but only 1 can dive at a time. The amount of time each welder can weld for depends on the depth he is diving to. So for example if he dives to 5 meters, then he can dive for 3 hours. If he dives to 20m, he can dive for 50 mins.
I have multiple locations at multiple depths that have to be welded, which I have broken onto seperate tasks.Can I allocate the 1 resource, ie a welder diver, and adjust the maximum work time for each task/location?
Thanks in advance.
Hi,When using ms project, is there any way I can have a maximum work time for a people resource.My issue is this:I am planning a diving job using welders. We have 6 welders but only 1 can dive at a time. The amount of time each welder can weld for depends on the depth he is diving to. So for example if he dives to 5 meters, then he can dive for 3 hours. If he dives to 20m, he can dive for 50 mins.I have multiple locations at multiple depths that have to be welded, which I have broken onto seperate tasks.Can I allocate the 1 resource, ie a welder diver, and adjust the maximum work time for each task/location?Thanks in advance. Read More