Month: June 2024
Ensuring each node becoming as CH exactly one time in LEACH
I am implementing my LEACH protocol. I want each of 100 nodes become as a CH exactly one time or in one round among 100 rounds. Below is the code snippet for CH making. In this code nodes become multiple time as CH, but i want exactly once. How to make it. Selecting one node uniquely based on probability in each round seems tricky.
close all;
clear all;
clc;
num_nodes = 100;
rounds = 100;
probability_threshold = 0.1;
% Initialize cluster heads
cluster_heads = zeros(rounds, num_nodes);
for r = 1:rounds
% Select cluster heads probabilistically
for i = 1:num_nodes
if rand <= probability_threshold %need to make exactly one node satisfy the condition
cluster_heads(r, i) = 1; % Node becomes a cluster head
end
end
end
Pls clarify!I am implementing my LEACH protocol. I want each of 100 nodes become as a CH exactly one time or in one round among 100 rounds. Below is the code snippet for CH making. In this code nodes become multiple time as CH, but i want exactly once. How to make it. Selecting one node uniquely based on probability in each round seems tricky.
close all;
clear all;
clc;
num_nodes = 100;
rounds = 100;
probability_threshold = 0.1;
% Initialize cluster heads
cluster_heads = zeros(rounds, num_nodes);
for r = 1:rounds
% Select cluster heads probabilistically
for i = 1:num_nodes
if rand <= probability_threshold %need to make exactly one node satisfy the condition
cluster_heads(r, i) = 1; % Node becomes a cluster head
end
end
end
Pls clarify! I am implementing my LEACH protocol. I want each of 100 nodes become as a CH exactly one time or in one round among 100 rounds. Below is the code snippet for CH making. In this code nodes become multiple time as CH, but i want exactly once. How to make it. Selecting one node uniquely based on probability in each round seems tricky.
close all;
clear all;
clc;
num_nodes = 100;
rounds = 100;
probability_threshold = 0.1;
% Initialize cluster heads
cluster_heads = zeros(rounds, num_nodes);
for r = 1:rounds
% Select cluster heads probabilistically
for i = 1:num_nodes
if rand <= probability_threshold %need to make exactly one node satisfy the condition
cluster_heads(r, i) = 1; % Node becomes a cluster head
end
end
end
Pls clarify! probability, leach MATLAB Answers — New Questions
Statistical test for an experiment involving three rat subjects with a within-subjects design and repeated measures
Which statistical test would be best for our experimental research where we want to examine the effect of deprivation schedules on the errors made by three rats over three days? We observed them and had them navigate a maze for three days, which all three rats experienced. We initially tried to use repeated measures ANOVA, but it showed NaN in the sphericity testWhich statistical test would be best for our experimental research where we want to examine the effect of deprivation schedules on the errors made by three rats over three days? We observed them and had them navigate a maze for three days, which all three rats experienced. We initially tried to use repeated measures ANOVA, but it showed NaN in the sphericity test Which statistical test would be best for our experimental research where we want to examine the effect of deprivation schedules on the errors made by three rats over three days? We observed them and had them navigate a maze for three days, which all three rats experienced. We initially tried to use repeated measures ANOVA, but it showed NaN in the sphericity test psychology, statistics, statistical help MATLAB Answers — New Questions
Sync-ModernMailPublicFolders.ps1 to remove MEPFs from Exchange Online – Limits to deletions?
Hi Folks,
We’re going to be disabling upwards of 5000 MEPFs in our on-prem Exchange (decommissioning many legacy folders) and are running the Sync-ModernMailPublicFolders.ps1 script daily at the moment to ensure changes are synced up to EXO. We have previously been disabling small numbers each day but are now ready to disable in bulk. I’m concerned that disabling such a large number at one time in our on-prem Exchange may not result in all the “deletions” occurring in EXO after a Sync-ModernMailPublicFolders.ps1 run. Is there a limit to the amount of these deletions in EXO (per day)? I’m considering options around batching these but would like to know if any limits on these deletions exist.
Thanks,
Michael
Hi Folks, We’re going to be disabling upwards of 5000 MEPFs in our on-prem Exchange (decommissioning many legacy folders) and are running the Sync-ModernMailPublicFolders.ps1 script daily at the moment to ensure changes are synced up to EXO. We have previously been disabling small numbers each day but are now ready to disable in bulk. I’m concerned that disabling such a large number at one time in our on-prem Exchange may not result in all the “deletions” occurring in EXO after a Sync-ModernMailPublicFolders.ps1 run. Is there a limit to the amount of these deletions in EXO (per day)? I’m considering options around batching these but would like to know if any limits on these deletions exist. Thanks,Michael Read More
workbench.aspx break when clicking “Preview”
On every web part I develop, running in /_layouts/15/workbench.aspx of all tenants I have access to, clicking the preview to debug, causes an error:
“Uncaught Error Error: The value for “domElement” must not be null
at e.isNotNullOrUndefined (res-1.cdn.office.net/files/sp-client/sp-webpart-workbench-assembly_en-us_a25d16d016d17db18ed91fbf7b537caf.js:20:183787″
I see it was reported in https://stackoverflow.com/ but no explanation or solution.
Please fix our workbench! Lots of SPFx developers are stock now.
Thank you
On every web part I develop, running in /_layouts/15/workbench.aspx of all tenants I have access to, clicking the preview to debug, causes an error:”Uncaught Error Error: The value for “domElement” must not be null
at e.isNotNullOrUndefined (res-1.cdn.office.net/files/sp-client/sp-webpart-workbench-assembly_en-us_a25d16d016d17db18ed91fbf7b537caf.js:20:183787″ I see it was reported in https://stackoverflow.com/ but no explanation or solution.Please fix our workbench! Lots of SPFx developers are stock now.Thank you Read More
How to run anova after fitlmematrix to obtain the F statistics
I am following the example of fitlmematrix under longitudinal data with a covariate at: https://www.mathworks.com/help/stats/fitlmematrix.html;
Breifly I build design matrix of the fixed and random effect for the model
y ~ Intercept + InitWeight + PrgB + PrgC + PrgD + Week + Week_PrgB + Week_PrgC + Week_PrgD + (Intercept + Week | Subject)
And then run the code:
lme = fitlmematrix(X,y,Z,G,’FixedEffectPredictors’,{‘Intercept’,’InitWeight’,’PrgB’,’PrgC’,’PrgD’,’Week’,’Week_PrgB’,’Week_PrgC’,’Week_PrgD’},’RandomEffectPredictors’,{{‘Intercept’,’Week’}},’RandomEffectGroups’,{‘Subject’})
I obtain the t-stats for each term:
Fixed effects coefficients (95% CIs):
Name Estimate SE tStat DF pValue Lower Upper
{‘Intercept’ } 0.66105 0.25892 2.5531 111 0.012034 0.14798 1.1741
{‘InitWeight’} 0.0031879 0.0013814 2.3078 111 0.022863 0.00045067 0.0059252
{‘PrgB’ } 0.36079 0.13139 2.746 111 0.0070394 0.10044 0.62113
{‘PrgC’ } -0.033263 0.13117 -0.25358 111 0.80029 -0.29319 0.22666
{‘PrgD’ } 0.11317 0.13132 0.86175 111 0.39068 -0.14706 0.3734
{‘Week’ } 0.1732 0.067454 2.5677 111 0.011567 0.039536 0.30686
{‘Week_PrgB’ } 0.038771 0.095394 0.40644 111 0.68521 -0.15026 0.2278
{‘Week_PrgC’ } 0.030543 0.095394 0.32018 111 0.74944 -0.15849 0.21957
{‘Week_PrgD’ } 0.033114 0.095394 0.34713 111 0.72915 -0.15592 0.22214
I am wondering, if it is possible to obtain a F-stats for all Programs (Prg). Anova(lme) in this case will give F-stats for individual terms instead of grouping them together.
Term FStat DF1 DF2 pValue
{‘Intercept’ } 6.5184 1 111 0.012034
{‘InitWeight’} 5.326 1 111 0.022863
{‘PrgB’ } 7.5406 1 111 0.0070394
{‘PrgC’ } 0.064305 1 111 0.80029
{‘PrgD’ } 0.74261 1 111 0.39068
{‘Week’ } 6.593 1 111 0.011567
{‘Week_PrgB’ } 0.16519 1 111 0.68521
{‘Week_PrgC’ } 0.10251 1 111 0.74944
{‘Week_PrgD’ } 0.1205 1 111 0.72915I am following the example of fitlmematrix under longitudinal data with a covariate at: https://www.mathworks.com/help/stats/fitlmematrix.html;
Breifly I build design matrix of the fixed and random effect for the model
y ~ Intercept + InitWeight + PrgB + PrgC + PrgD + Week + Week_PrgB + Week_PrgC + Week_PrgD + (Intercept + Week | Subject)
And then run the code:
lme = fitlmematrix(X,y,Z,G,’FixedEffectPredictors’,{‘Intercept’,’InitWeight’,’PrgB’,’PrgC’,’PrgD’,’Week’,’Week_PrgB’,’Week_PrgC’,’Week_PrgD’},’RandomEffectPredictors’,{{‘Intercept’,’Week’}},’RandomEffectGroups’,{‘Subject’})
I obtain the t-stats for each term:
Fixed effects coefficients (95% CIs):
Name Estimate SE tStat DF pValue Lower Upper
{‘Intercept’ } 0.66105 0.25892 2.5531 111 0.012034 0.14798 1.1741
{‘InitWeight’} 0.0031879 0.0013814 2.3078 111 0.022863 0.00045067 0.0059252
{‘PrgB’ } 0.36079 0.13139 2.746 111 0.0070394 0.10044 0.62113
{‘PrgC’ } -0.033263 0.13117 -0.25358 111 0.80029 -0.29319 0.22666
{‘PrgD’ } 0.11317 0.13132 0.86175 111 0.39068 -0.14706 0.3734
{‘Week’ } 0.1732 0.067454 2.5677 111 0.011567 0.039536 0.30686
{‘Week_PrgB’ } 0.038771 0.095394 0.40644 111 0.68521 -0.15026 0.2278
{‘Week_PrgC’ } 0.030543 0.095394 0.32018 111 0.74944 -0.15849 0.21957
{‘Week_PrgD’ } 0.033114 0.095394 0.34713 111 0.72915 -0.15592 0.22214
I am wondering, if it is possible to obtain a F-stats for all Programs (Prg). Anova(lme) in this case will give F-stats for individual terms instead of grouping them together.
Term FStat DF1 DF2 pValue
{‘Intercept’ } 6.5184 1 111 0.012034
{‘InitWeight’} 5.326 1 111 0.022863
{‘PrgB’ } 7.5406 1 111 0.0070394
{‘PrgC’ } 0.064305 1 111 0.80029
{‘PrgD’ } 0.74261 1 111 0.39068
{‘Week’ } 6.593 1 111 0.011567
{‘Week_PrgB’ } 0.16519 1 111 0.68521
{‘Week_PrgC’ } 0.10251 1 111 0.74944
{‘Week_PrgD’ } 0.1205 1 111 0.72915 I am following the example of fitlmematrix under longitudinal data with a covariate at: https://www.mathworks.com/help/stats/fitlmematrix.html;
Breifly I build design matrix of the fixed and random effect for the model
y ~ Intercept + InitWeight + PrgB + PrgC + PrgD + Week + Week_PrgB + Week_PrgC + Week_PrgD + (Intercept + Week | Subject)
And then run the code:
lme = fitlmematrix(X,y,Z,G,’FixedEffectPredictors’,{‘Intercept’,’InitWeight’,’PrgB’,’PrgC’,’PrgD’,’Week’,’Week_PrgB’,’Week_PrgC’,’Week_PrgD’},’RandomEffectPredictors’,{{‘Intercept’,’Week’}},’RandomEffectGroups’,{‘Subject’})
I obtain the t-stats for each term:
Fixed effects coefficients (95% CIs):
Name Estimate SE tStat DF pValue Lower Upper
{‘Intercept’ } 0.66105 0.25892 2.5531 111 0.012034 0.14798 1.1741
{‘InitWeight’} 0.0031879 0.0013814 2.3078 111 0.022863 0.00045067 0.0059252
{‘PrgB’ } 0.36079 0.13139 2.746 111 0.0070394 0.10044 0.62113
{‘PrgC’ } -0.033263 0.13117 -0.25358 111 0.80029 -0.29319 0.22666
{‘PrgD’ } 0.11317 0.13132 0.86175 111 0.39068 -0.14706 0.3734
{‘Week’ } 0.1732 0.067454 2.5677 111 0.011567 0.039536 0.30686
{‘Week_PrgB’ } 0.038771 0.095394 0.40644 111 0.68521 -0.15026 0.2278
{‘Week_PrgC’ } 0.030543 0.095394 0.32018 111 0.74944 -0.15849 0.21957
{‘Week_PrgD’ } 0.033114 0.095394 0.34713 111 0.72915 -0.15592 0.22214
I am wondering, if it is possible to obtain a F-stats for all Programs (Prg). Anova(lme) in this case will give F-stats for individual terms instead of grouping them together.
Term FStat DF1 DF2 pValue
{‘Intercept’ } 6.5184 1 111 0.012034
{‘InitWeight’} 5.326 1 111 0.022863
{‘PrgB’ } 7.5406 1 111 0.0070394
{‘PrgC’ } 0.064305 1 111 0.80029
{‘PrgD’ } 0.74261 1 111 0.39068
{‘Week’ } 6.593 1 111 0.011567
{‘Week_PrgB’ } 0.16519 1 111 0.68521
{‘Week_PrgC’ } 0.10251 1 111 0.74944
{‘Week_PrgD’ } 0.1205 1 111 0.72915 fitlmematrix MATLAB Answers — New Questions
Windows Security suddenly thinks my compiled app contains a virus
Today (2023.07.30) Windows Security updated its "don’t like" list on my machine and now it won’t start/quarantines the app I’ve been building on R2015b for years. I got around it by excluding the app’s installation folder from Windows Security but I find this worrying, especially since this app gets distributed to many others.
Anyone else seen this or have any ideas?
Thank you.Today (2023.07.30) Windows Security updated its "don’t like" list on my machine and now it won’t start/quarantines the app I’ve been building on R2015b for years. I got around it by excluding the app’s installation folder from Windows Security but I find this worrying, especially since this app gets distributed to many others.
Anyone else seen this or have any ideas?
Thank you. Today (2023.07.30) Windows Security updated its "don’t like" list on my machine and now it won’t start/quarantines the app I’ve been building on R2015b for years. I got around it by excluding the app’s installation folder from Windows Security but I find this worrying, especially since this app gets distributed to many others.
Anyone else seen this or have any ideas?
Thank you. windows security, virus, compiled app, matlab r2015b MATLAB Answers — New Questions
How do I solve a system using rkf45 method with shooing technique?
I tried to solve a ode system using rk method with shooing technique. But I have a lot of errors. How can I solve this issue.
function bvp_shooting_rk_2()
% Define constants and parameters
rho_f = 783; rCp_f = 2090 * rho_f; k_f = 0.145; rb_f = 21e-6; Pr = 6;
rho_s1 = 1800; rCp_s1 = 717 * rho_s1; k_s1 = 5000; rb_s1 = 6.30e7;
rho_s2 = 10500; rCp_s2 = 235 * rho_s2; k_s2 = 429; rb_s2 = 63e-6;
m = 3; phi_s1 = 0.01; phi_s2 = 0.01; M = 0; K_p = 0.5; beta = 0.5;
S = 0.5; % Initial condition for theta at eta = 0
B_i = 0.5; Q = 0.01; Ec = 0.8;
% Assume values for mu_f and sigma_f, as they are not defined in the problem
mu_f = 1; % Dynamic viscosity of the base fluid (assumed)
sigma_f = 1; % Electrical conductivity of the base fluid (assumed)
rho_hnf = (1-phi_s2)*((1-phi_s1)*rho_f + phi_s1*rho_s1) + phi_s2*rho_s2;
rCp_hnf = (1-phi_s2)*((1-phi_s1)*rCp_f + phi_s1*rCp_s1) + phi_s2*rCp_s2;
mu_hnf = mu_f / ((1-phi_s1)^2.5 * (1-phi_s2)^2.5);
k_bf = k_f * (k_s1 + (m-1)*k_f – (m-1)*phi_s1*(k_f – k_s1)) / (k_s1 + (m-1)*k_f – phi_s1*(k_f – k_s1));
k_hnf = k_bf * (k_s2 + (m-1)*k_bf – (m-1)*phi_s2*(k_bf – k_s2)) / (k_s2 + (m-1)*k_bf – phi_s2*(k_bf – k_s2));
rb_hnf = (1-phi_s2)*((1-phi_s1)*rb_f + phi_s1*rb_s1) + phi_s2*rb_s2;
sigma_bf = sigma_f * (1-phi_s1)^2.5;
sigma_hnf = sigma_bf * (1-phi_s2)^2.5;
A1 = (1-phi_s1)^2.5 * (1-phi_s2)^2.5 * ((1-phi_s2)*(1-phi_s1 + phi_s1*rho_s1/rho_f) + phi_s2*rho_s2/rho_f);
A2 = (1-phi_s2) * (1-phi_s1 + phi_s1*rho_s1/rho_f) + phi_s2*rho_s2/rho_f;
A3 = (1-phi_s2) * (1-phi_s1 + phi_s1*rCp_s1/rCp_f) + phi_s2*rCp_s2/rCp_f;
A4 = (1-phi_s1)^2.5 * (1-phi_s2)^2.5;
% Initial guess for the shooting method
xi_guess = [1; 1]; % Initial guesses for f”(0) and theta'(0)
eta_end = 25; % End of the interval
tol = 1e-6; % Tolerance
% Solve the BVP using the shooting method
[xi, y, eta] = shooting_method(xi_guess, eta_end, tol, A1, A2, A3, A4, K_p, beta, Pr, k_f, k_hnf, Q, Ec, S);
% Plot the solution
figure;
subplot(2, 1, 1);
plot(eta, y(:, 1), ‘b-‘, ‘LineWidth’, 2);
xlabel(‘eta’);
ylabel(‘f(eta)’);
title(‘Solution for f(eta) using Shooting Method with RK’);
grid on;
subplot(2, 1, 2);
plot(eta, y(:, 4), ‘r-‘, ‘LineWidth’, 2);
xlabel(‘eta’);
ylabel(‘theta(eta)’);
title(‘Solution for theta(eta) using Shooting Method with RK’);
grid on;
end
function [xi, y, eta] = shooting_method(xi_guess, eta_end, tol, A1, A2, A3, A4, K_p, beta, Pr, k_f, k_hnf, Q, Ec, S)
% Shooting method to adjust xi
options = odeset(‘RelTol’, 1e-6, ‘AbsTol’, 1e-6);
% Initial conditions
y0 = [0; 1; xi_guess(1); S; xi_guess(2)]; % Initial conditions including S for theta at eta = 0
% Solve the ODE system
[eta, y] = ode45(@(eta, y) ode_system(eta, y, A1, A2, A3, A4, K_p, beta, Pr, k_f, k_hnf, Q, Ec), [0 eta_end], y0, options);
% Check the boundary condition at eta_end
bc_error_f_prime = y(end, 2); % f'(eta_end) should be 0
bc_error_theta = y(end, 4); % theta(eta_end) should be 0
% Adjust xi using a simple iteration (could use a more sophisticated method)
xi_new = xi_guess;
iteration_count = 0;
max_iterations = 100; % Limit the number of iterations to prevent infinite loops
while (abs(bc_error_f_prime) > tol || abs(bc_error_theta) > tol) && iteration_count < max_iterations
% Simple adjustment step
xi_new(1) = xi_new(1) – bc_error_f_prime * 0.1;
xi_new(2) = xi_new(2) – bc_error_theta * 0.1;
y0 = [0; 1; xi_new(1); S; xi_new(2)];
[eta, y] = ode45(@(eta, y) ode_system(eta, y, A1, A2, A3, A4, K_p, beta, Pr, k_f, k_hnf, Q, Ec, M), [0 eta_end], y0, options);
bc_error_f_prime = y(end, 2);
bc_error_theta = y(end, 4);
iteration_count = iteration_count + 1;
end
if iteration_count >= max_iterations
error(‘Shooting method failed to converge.’);
end
xi = xi_new;
end
function dydeta = ode_system(eta, y, A1, A2, A3, A4, K_p, beta, Pr, k_f, k_hnf, Q, Ec, M)
% Extract variables from y
f = y(1);
f_prime = y(2);
f_double_prime = y(3);
theta = y(4);
theta_prime = y(5);
% Define the system of ODEs
f_triple_prime = A1 * ((f_prime)^2 – f * f_double_prime) + A2 * M * f_prime + K_p * f_prime – beta * A1 * (f^2 * f_triple_prime – 2 * f * f_prime * f_double_prime);
theta_double_prime = k_f * Pr * (A3 * f * theta_prime – Ec * A4 * (f_double_prime)^2 – Q * theta) / k_hnf;
% Return derivatives as a column vector
dydeta = [f_prime; f_double_prime; f_triple_prime; theta_prime; theta_double_prime];
endI tried to solve a ode system using rk method with shooing technique. But I have a lot of errors. How can I solve this issue.
function bvp_shooting_rk_2()
% Define constants and parameters
rho_f = 783; rCp_f = 2090 * rho_f; k_f = 0.145; rb_f = 21e-6; Pr = 6;
rho_s1 = 1800; rCp_s1 = 717 * rho_s1; k_s1 = 5000; rb_s1 = 6.30e7;
rho_s2 = 10500; rCp_s2 = 235 * rho_s2; k_s2 = 429; rb_s2 = 63e-6;
m = 3; phi_s1 = 0.01; phi_s2 = 0.01; M = 0; K_p = 0.5; beta = 0.5;
S = 0.5; % Initial condition for theta at eta = 0
B_i = 0.5; Q = 0.01; Ec = 0.8;
% Assume values for mu_f and sigma_f, as they are not defined in the problem
mu_f = 1; % Dynamic viscosity of the base fluid (assumed)
sigma_f = 1; % Electrical conductivity of the base fluid (assumed)
rho_hnf = (1-phi_s2)*((1-phi_s1)*rho_f + phi_s1*rho_s1) + phi_s2*rho_s2;
rCp_hnf = (1-phi_s2)*((1-phi_s1)*rCp_f + phi_s1*rCp_s1) + phi_s2*rCp_s2;
mu_hnf = mu_f / ((1-phi_s1)^2.5 * (1-phi_s2)^2.5);
k_bf = k_f * (k_s1 + (m-1)*k_f – (m-1)*phi_s1*(k_f – k_s1)) / (k_s1 + (m-1)*k_f – phi_s1*(k_f – k_s1));
k_hnf = k_bf * (k_s2 + (m-1)*k_bf – (m-1)*phi_s2*(k_bf – k_s2)) / (k_s2 + (m-1)*k_bf – phi_s2*(k_bf – k_s2));
rb_hnf = (1-phi_s2)*((1-phi_s1)*rb_f + phi_s1*rb_s1) + phi_s2*rb_s2;
sigma_bf = sigma_f * (1-phi_s1)^2.5;
sigma_hnf = sigma_bf * (1-phi_s2)^2.5;
A1 = (1-phi_s1)^2.5 * (1-phi_s2)^2.5 * ((1-phi_s2)*(1-phi_s1 + phi_s1*rho_s1/rho_f) + phi_s2*rho_s2/rho_f);
A2 = (1-phi_s2) * (1-phi_s1 + phi_s1*rho_s1/rho_f) + phi_s2*rho_s2/rho_f;
A3 = (1-phi_s2) * (1-phi_s1 + phi_s1*rCp_s1/rCp_f) + phi_s2*rCp_s2/rCp_f;
A4 = (1-phi_s1)^2.5 * (1-phi_s2)^2.5;
% Initial guess for the shooting method
xi_guess = [1; 1]; % Initial guesses for f”(0) and theta'(0)
eta_end = 25; % End of the interval
tol = 1e-6; % Tolerance
% Solve the BVP using the shooting method
[xi, y, eta] = shooting_method(xi_guess, eta_end, tol, A1, A2, A3, A4, K_p, beta, Pr, k_f, k_hnf, Q, Ec, S);
% Plot the solution
figure;
subplot(2, 1, 1);
plot(eta, y(:, 1), ‘b-‘, ‘LineWidth’, 2);
xlabel(‘eta’);
ylabel(‘f(eta)’);
title(‘Solution for f(eta) using Shooting Method with RK’);
grid on;
subplot(2, 1, 2);
plot(eta, y(:, 4), ‘r-‘, ‘LineWidth’, 2);
xlabel(‘eta’);
ylabel(‘theta(eta)’);
title(‘Solution for theta(eta) using Shooting Method with RK’);
grid on;
end
function [xi, y, eta] = shooting_method(xi_guess, eta_end, tol, A1, A2, A3, A4, K_p, beta, Pr, k_f, k_hnf, Q, Ec, S)
% Shooting method to adjust xi
options = odeset(‘RelTol’, 1e-6, ‘AbsTol’, 1e-6);
% Initial conditions
y0 = [0; 1; xi_guess(1); S; xi_guess(2)]; % Initial conditions including S for theta at eta = 0
% Solve the ODE system
[eta, y] = ode45(@(eta, y) ode_system(eta, y, A1, A2, A3, A4, K_p, beta, Pr, k_f, k_hnf, Q, Ec), [0 eta_end], y0, options);
% Check the boundary condition at eta_end
bc_error_f_prime = y(end, 2); % f'(eta_end) should be 0
bc_error_theta = y(end, 4); % theta(eta_end) should be 0
% Adjust xi using a simple iteration (could use a more sophisticated method)
xi_new = xi_guess;
iteration_count = 0;
max_iterations = 100; % Limit the number of iterations to prevent infinite loops
while (abs(bc_error_f_prime) > tol || abs(bc_error_theta) > tol) && iteration_count < max_iterations
% Simple adjustment step
xi_new(1) = xi_new(1) – bc_error_f_prime * 0.1;
xi_new(2) = xi_new(2) – bc_error_theta * 0.1;
y0 = [0; 1; xi_new(1); S; xi_new(2)];
[eta, y] = ode45(@(eta, y) ode_system(eta, y, A1, A2, A3, A4, K_p, beta, Pr, k_f, k_hnf, Q, Ec, M), [0 eta_end], y0, options);
bc_error_f_prime = y(end, 2);
bc_error_theta = y(end, 4);
iteration_count = iteration_count + 1;
end
if iteration_count >= max_iterations
error(‘Shooting method failed to converge.’);
end
xi = xi_new;
end
function dydeta = ode_system(eta, y, A1, A2, A3, A4, K_p, beta, Pr, k_f, k_hnf, Q, Ec, M)
% Extract variables from y
f = y(1);
f_prime = y(2);
f_double_prime = y(3);
theta = y(4);
theta_prime = y(5);
% Define the system of ODEs
f_triple_prime = A1 * ((f_prime)^2 – f * f_double_prime) + A2 * M * f_prime + K_p * f_prime – beta * A1 * (f^2 * f_triple_prime – 2 * f * f_prime * f_double_prime);
theta_double_prime = k_f * Pr * (A3 * f * theta_prime – Ec * A4 * (f_double_prime)^2 – Q * theta) / k_hnf;
% Return derivatives as a column vector
dydeta = [f_prime; f_double_prime; f_triple_prime; theta_prime; theta_double_prime];
end I tried to solve a ode system using rk method with shooing technique. But I have a lot of errors. How can I solve this issue.
function bvp_shooting_rk_2()
% Define constants and parameters
rho_f = 783; rCp_f = 2090 * rho_f; k_f = 0.145; rb_f = 21e-6; Pr = 6;
rho_s1 = 1800; rCp_s1 = 717 * rho_s1; k_s1 = 5000; rb_s1 = 6.30e7;
rho_s2 = 10500; rCp_s2 = 235 * rho_s2; k_s2 = 429; rb_s2 = 63e-6;
m = 3; phi_s1 = 0.01; phi_s2 = 0.01; M = 0; K_p = 0.5; beta = 0.5;
S = 0.5; % Initial condition for theta at eta = 0
B_i = 0.5; Q = 0.01; Ec = 0.8;
% Assume values for mu_f and sigma_f, as they are not defined in the problem
mu_f = 1; % Dynamic viscosity of the base fluid (assumed)
sigma_f = 1; % Electrical conductivity of the base fluid (assumed)
rho_hnf = (1-phi_s2)*((1-phi_s1)*rho_f + phi_s1*rho_s1) + phi_s2*rho_s2;
rCp_hnf = (1-phi_s2)*((1-phi_s1)*rCp_f + phi_s1*rCp_s1) + phi_s2*rCp_s2;
mu_hnf = mu_f / ((1-phi_s1)^2.5 * (1-phi_s2)^2.5);
k_bf = k_f * (k_s1 + (m-1)*k_f – (m-1)*phi_s1*(k_f – k_s1)) / (k_s1 + (m-1)*k_f – phi_s1*(k_f – k_s1));
k_hnf = k_bf * (k_s2 + (m-1)*k_bf – (m-1)*phi_s2*(k_bf – k_s2)) / (k_s2 + (m-1)*k_bf – phi_s2*(k_bf – k_s2));
rb_hnf = (1-phi_s2)*((1-phi_s1)*rb_f + phi_s1*rb_s1) + phi_s2*rb_s2;
sigma_bf = sigma_f * (1-phi_s1)^2.5;
sigma_hnf = sigma_bf * (1-phi_s2)^2.5;
A1 = (1-phi_s1)^2.5 * (1-phi_s2)^2.5 * ((1-phi_s2)*(1-phi_s1 + phi_s1*rho_s1/rho_f) + phi_s2*rho_s2/rho_f);
A2 = (1-phi_s2) * (1-phi_s1 + phi_s1*rho_s1/rho_f) + phi_s2*rho_s2/rho_f;
A3 = (1-phi_s2) * (1-phi_s1 + phi_s1*rCp_s1/rCp_f) + phi_s2*rCp_s2/rCp_f;
A4 = (1-phi_s1)^2.5 * (1-phi_s2)^2.5;
% Initial guess for the shooting method
xi_guess = [1; 1]; % Initial guesses for f”(0) and theta'(0)
eta_end = 25; % End of the interval
tol = 1e-6; % Tolerance
% Solve the BVP using the shooting method
[xi, y, eta] = shooting_method(xi_guess, eta_end, tol, A1, A2, A3, A4, K_p, beta, Pr, k_f, k_hnf, Q, Ec, S);
% Plot the solution
figure;
subplot(2, 1, 1);
plot(eta, y(:, 1), ‘b-‘, ‘LineWidth’, 2);
xlabel(‘eta’);
ylabel(‘f(eta)’);
title(‘Solution for f(eta) using Shooting Method with RK’);
grid on;
subplot(2, 1, 2);
plot(eta, y(:, 4), ‘r-‘, ‘LineWidth’, 2);
xlabel(‘eta’);
ylabel(‘theta(eta)’);
title(‘Solution for theta(eta) using Shooting Method with RK’);
grid on;
end
function [xi, y, eta] = shooting_method(xi_guess, eta_end, tol, A1, A2, A3, A4, K_p, beta, Pr, k_f, k_hnf, Q, Ec, S)
% Shooting method to adjust xi
options = odeset(‘RelTol’, 1e-6, ‘AbsTol’, 1e-6);
% Initial conditions
y0 = [0; 1; xi_guess(1); S; xi_guess(2)]; % Initial conditions including S for theta at eta = 0
% Solve the ODE system
[eta, y] = ode45(@(eta, y) ode_system(eta, y, A1, A2, A3, A4, K_p, beta, Pr, k_f, k_hnf, Q, Ec), [0 eta_end], y0, options);
% Check the boundary condition at eta_end
bc_error_f_prime = y(end, 2); % f'(eta_end) should be 0
bc_error_theta = y(end, 4); % theta(eta_end) should be 0
% Adjust xi using a simple iteration (could use a more sophisticated method)
xi_new = xi_guess;
iteration_count = 0;
max_iterations = 100; % Limit the number of iterations to prevent infinite loops
while (abs(bc_error_f_prime) > tol || abs(bc_error_theta) > tol) && iteration_count < max_iterations
% Simple adjustment step
xi_new(1) = xi_new(1) – bc_error_f_prime * 0.1;
xi_new(2) = xi_new(2) – bc_error_theta * 0.1;
y0 = [0; 1; xi_new(1); S; xi_new(2)];
[eta, y] = ode45(@(eta, y) ode_system(eta, y, A1, A2, A3, A4, K_p, beta, Pr, k_f, k_hnf, Q, Ec, M), [0 eta_end], y0, options);
bc_error_f_prime = y(end, 2);
bc_error_theta = y(end, 4);
iteration_count = iteration_count + 1;
end
if iteration_count >= max_iterations
error(‘Shooting method failed to converge.’);
end
xi = xi_new;
end
function dydeta = ode_system(eta, y, A1, A2, A3, A4, K_p, beta, Pr, k_f, k_hnf, Q, Ec, M)
% Extract variables from y
f = y(1);
f_prime = y(2);
f_double_prime = y(3);
theta = y(4);
theta_prime = y(5);
% Define the system of ODEs
f_triple_prime = A1 * ((f_prime)^2 – f * f_double_prime) + A2 * M * f_prime + K_p * f_prime – beta * A1 * (f^2 * f_triple_prime – 2 * f * f_prime * f_double_prime);
theta_double_prime = k_f * Pr * (A3 * f * theta_prime – Ec * A4 * (f_double_prime)^2 – Q * theta) / k_hnf;
% Return derivatives as a column vector
dydeta = [f_prime; f_double_prime; f_triple_prime; theta_prime; theta_double_prime];
end shooting, rkf45 method MATLAB Answers — New Questions
Onscreen display
Workbook I created 10 years ago and use monthly–I have column headings displayed regardless of how far down I have gone–until today. How can I make them show up on the top of the screen I am working on (and why have they disappeared).
Workbook I created 10 years ago and use monthly–I have column headings displayed regardless of how far down I have gone–until today. How can I make them show up on the top of the screen I am working on (and why have they disappeared). Read More
Exploring Generative AI: A Hands-on Course on Prompt Engineering for non-tech students – Part 2
Introduction
Welcome to Part 2 of our exploration into generative AI, where we delve deeper into the practical applications and creative potential of this innovative technology.
This article highlights concrete examples from students projects of the course ‘Prompt Engineering’ at Fondazione Bruno Kessler (FBK) in Trento (Italy). The aim is to showcase how students leveraged generative AI in unique ways. In particular, we’ll focus on two fascinating projects: “Generative Music” and “Personal Chef,” which exemplify the versatility and impact of generative AI in diverse fields.
Core element of these projects is the use of a structured framework known as the Card Model to define and organize generative AI tasks. In the context of this course, a card refers to a structured format or template used to define a specific task or objective for generating content or output using generative AI techniques. The Flow of these cards, meaning the logical sequence and interaction between them, is crucial for the coherent generation of complex outputs. For a detailed explanation of Card and Flow concepts read the 1st part of this blog series.
Our students have been actively experimenting with generative AI, producing remarkable results in their projects. Here, we present detailed insights and experiences from their hands-on work, demonstrating the practical applications of prompt engineering with non-tech students.
Generative Music
The “Generative Music” project leverages generative AI technology to innovate the music creation process. Central to this project is the use of Generative AI Cards that define various musical parameters and guide the AI in generating unique compositions. Generative AI Cards specify key musical elements such as genre, number of chords, melody length, key, and instrumentation, including bass and guitar (Fig. 1). Each card represents a distinct aspect of the music, allowing for precise control over the generated content. By configuring these cards, the team can tailor the AI’s output to meet specific creative goals.
Card Configuration
The process begins with the selection and configuration of these cards. Initial configurations often require multiple iterations to achieve satisfactory results. Each card’s parameters are adjusted to optimize the music generation, focusing on refining the elements to create a harmonious and appealing output.
Fig 1: Example of Cards from the Music Project.
Flow Generation
Flow generation involves the structured combination of these AI Cards to produce a coherent piece of music. This stage is crucial as it dictates the sequence and interaction of different musical components defined by the cards. The project utilizes tools like Canva to aid in visualizing and organizing the flow of these components, ensuring a smooth and logical progression in the music. During the flow generation process, the order of the AI Cards is experimented to explore different musical outcomes. However, the team found that altering the sequence did not significantly affect the final output, indicating that the cards’ individual configurations are more critical than their order.
Iterative Refinement and Human Interaction
A significant aspect of the project is the iterative refinement process, where generated music undergoes multiple evaluations and adjustments. Human intervention is essential at this stage to validate the quality of the output. Listening to the music is the primary method for assessing its adequacy, as human judgment is necessary to determine whether the AI’s creation meets the desired standards. The team continuously modifies the prompts and configurations of the AI Cards based on feedback, refining the generative process to improve the music quality. This iterative cycle of generation, evaluation, and adjustment ensures that the final product aligns with the creative vision (Fig. 2).
Fig 2: genAI music showcase (youtube.com)
Lessons Learnt
The “Generative Music” project demonstrates the potential of generative AI in the field of music creation. By using Generative AI Cards and structured flow generation, the project showcases a methodical approach to producing unique musical compositions. Despite the need for substantial human involvement in the refinement process, this innovative use of AI represents a significant step forward in integrating technology with artistic creativity.
Personal Chef
The “Personal Chef” project utilizes generative AI to assist individuals in planning balanced meals efficiently. The primary goal of this project is to save time and resources, enhance creativity, and provide valuable insights for meal planning. Generative AI Cards are central to this project, serving as modular components that define specific meal planning parameters. Each card encapsulates different aspects of meal creation, such as the type of dish (e.g., balanced dish, vegetarian alternative), the ingredients required, and the nutritional composition (Fig. 3). These cards help in structuring the meal planning process by providing detailed instructions and alternatives based on user preferences and dietary needs.
Card Configuration
For instance, one AI Card might focus on generating a list of high-protein foods, while another might ensure the meal components are seasonal. These cards are iteratively refined based on user feedback to ensure they deliver precise and relevant outputs. The language used in these cards is carefully chosen, as even small changes can significantly impact the results. The feedback loop is crucial here, as it allows continuous improvement and ensures that the AI provides more accurate and context-specific suggestions over time.
Fig 3: Example of Cards from the Personal Chef Project.
Flow Generation
Flow generation in this project involves the logical sequencing and combination of Generative AI Cards to create coherent and balanced meal plans. This process ensures that the output not only meets nutritional guidelines but also aligns with the user’s preferences and constraints. The flow of these cards is designed to cover various stages of meal planning, from selecting ingredients to proposing complete dishes (Fig. 4). For example, a flow might start with an AI Card that provides a balanced dish recipe, followed by another card that suggests a vegetarian alternative, and then a card that customizes the dish based on seasonal ingredients. This structured approach ensures a logical progression and maintains the relevance and coherence of the meal plans.
Fig 4: Example of Flows from the Personal Chef Project.
Iterative Refinement and Human Interaction
The project emphasizes the importance of human feedback in refining the AI-generated outputs. Users can interact with the system to customize the generated meal plans, adding or removing ingredients as needed. This iterative process ensures that the AI’s suggestions remain practical and tailored to individual preferences and dietary requirements. By continuously incorporating user feedback, the project aims to enhance the precision and utility of the Generative AI Cards, ultimately making the meal planning process more efficient and enjoyable.
Lessons Learnt
The “Personal Chef” project showcases how generative AI can be leveraged to support everyday tasks like meal planning. The use of Generative AI Cards allows for a modular and flexible approach, enabling users to create personalized and balanced meal plans. While the AI can provide valuable insights and save time, human interaction remains essential to validate and refine the outputs, ensuring they meet the users’ specific needs and preferences. This integration of AI and human expertise represents a significant advancement in making daily routines more manageable and creative.
Students Survey Results
The class consisted of 11 students (average age 23, 5 female) from various university faculties, i.e. Psychology, Cognitive Science, Human-Computer Interaction.
As said, it was a class of non-tech students. Indeed, most of them (7 out of 11) stated that they rarely (1-4 times in the last month) used tools such as ChatGPT. Only one student stated that he/she regularly (every day or almost every day) used these tools, either for study-related and unrelated purposes. One student admitted that he/she was not familiar with ChaptGPT, had only heard about it but had never used it.
In order to investigate the students’ knowledge of GenAI and its potential and to assess the effectiveness or otherwise of the course in increasing their knowledge and ability to use GenAI, we administered a questionnaire at the beginning and end of the course and then made comparisons.
The questionnaire consists of 50 items taken from existing surveys [1,2] investigating various dimensions concerning AI in general. These included: (a) AI Literacy, based on the level of knowledge, understanding and ability to use AI, (b) Anxiety, related to the fear of not being able to learn how to use AI correctly, as well as of losing one’s reasoning and control abilities, and (c) Self-Efficacy, related to confidence both in one’s technical capabilities and in AI as good aid to learning.
As evident from the graph below (Fig. 5), by comparing the answers given by the students before and after the course, it is evident that on average the students increased their literacy and self-efficacy, and decreased their anxiety.
Fig. 5:. Average scores of students’ literacy, anxiety and self-efficacy gathered at the beginning and the end of the Prompt Engineering course for non-tech students.
Furthermore, at the end of the course we asked the students to answer 10 additional questions aimed at gathering their feedback specifically about Generative AI. In particular, we asked them to score the following statements using a 7-point Likert scale, where 1 means “strongly disagree” and 7 means “strongly agree”:
I increased my knowledge and understanding of GenAI
I can effectively use GenAI
When interacting with technology, I am now aware of the possible use of GenAI
I am aware of the ethical implications when using AI-based applications
Taking a class on Prompt Engineering for Generative AI made me anxious
I am afraid that by using AI systems I will become lazy and lose some of my reasoning skills
AI malfunctioning can cause many problems
If used appropriately, GenAI is a valuable learning support
When using GenAI, I feel comfortable
I significantly increased my technological skills
Fig. 6 presents the average score and standard deviation of each item. As evident from the graph, after the course the students recognised the value of GenAI as a valuable tool to support learning (item 8). They also showed to be more aware of the possible uses of GenAI (item 3) and ethical implications of such uses (item 4), whereas they showed a low level of anxiety in attending the course (item 5) and a low level of fear of losing reasoning skills (item 6).
Fig. 6: Average scores on a 7-point Likert scale given by non-tech students at the end of the Prompt Engineering course.
Conclusions
Generative AI is widely used in higher education and skills training. Articles like [3] demonstrate that Generative AI is widely used in higher education and skills training, highlighting its benefits for productivity and efficiency, alongside concerns about overdependence and superficial learning. In Part 2 of our blog series, we delved into the practical applications and creative potential of this innovative technology. Through projects like “Generative Music” and “Personal Chef,” our students demonstrated the versatility and impact of generative AI across diverse fields. Central to these projects was the structured framework known as the Card Model and a Flow of the identified cards, which helped define and organize generative AI tasks.
The course significantly enhanced students’ understanding of prompt engineering, reducing their anxiety and increasing their self-efficacy. Survey results indicated improved AI literacy and decreased anxiety, with students feeling more confident in their technical abilities and recognizing the value of generative AI as a learning tool. Utilizing atomic cards to define and organize generative AI tasks facilitated the learning process. This structured approach allowed students to better grasp and control various aspects of content generation. In the “Generative Music” and “Personal Chef” projects, the cards provided a flexible and modular framework, enabling iterative refinement and improved output quality.
Looking ahead, future developments could further enhance the effectiveness of teaching generative AI. Developing specific tools and editors for configuring prompts could simplify the process, making it more intuitive for students. Establishing standard guidelines and metrics for evaluating generative outputs could provide more structured feedback, improving the learning process. Additionally, expanding the course content to include a broader range of diverse and complex case studies could help students explore more generative AI applications, deepening their understanding and innovative capabilities.
These advancements would not only improve the teaching of generative AI but also promote greater integration of technology and creativity, better preparing students for their future professional career.
Antonio Bucchiarone
Motivational Digital System (MoDiS)
Fondazione Bruno Kessler (FBK), Trento – Italy
Nadia Mana
Intelligent Interfaces and Interaction (i3)
Fondazione Bruno Kessler (FBK), Trento – Italy
References
[1] Schiavo, Gianluca and Businaro, Stefano and Zancanaro, Massimo. Comprehension, Apprehension, and Acceptance: Understanding the Influence of Literacy and Anxiety on Acceptance of Artificial Intelligence. Available at SSRN: https://ssrn.com/abstract=4668256.
[2] Wang, Y. M., Wei, C. L., Lin, H. H., Wang, S. C., & Wang, Y. S. (2022). What drives students’ AI learning behavior: a perspective of AI anxiety. Interactive Learning Environments, 1–17. https://doi.org/10.1080/10494820.2022.2153147
[3] Hadi Mogavi, Reza and Deng, Chao and Juho Kim, Justin and Zhou, Pengyuan and D. Kwon, Young and Hosny Saleh Metwally, Ahmed and Tlili, Ahmed and Bassanelli, Simone and Bucchiarone, Antonio and Gujar, Sujit and Nacke, Lennart E. and Hui, Pan. ChatGPT in education: A blessing or a curse? A qualitative study exploring early adopters’ utilization and perceptions. Computers in Human Behavior: Artificial Humans, Vol. 2, N. 1, 2024. https://doi.org/10.1016/j.chbah.2023.100027
Microsoft Tech Community – Latest Blogs –Read More
COUNTIF
Hi,
I am using tge COUNTIF function to count cells in a range with a ‘tick’ symbol. I would like to show the result as the cells counted is % of total cells in the range. Could someone please assist with the relevant syntax?
Thankyou
Hi,I am using tge COUNTIF function to count cells in a range with a ‘tick’ symbol. I would like to show the result as the cells counted is % of total cells in the range. Could someone please assist with the relevant syntax?Thankyou Read More
MACRO generation in C-code using embedded coder
Is there an alternative way other than defining a simulink.paramater to generate #define MACROs in c code using embedded coder?Is there an alternative way other than defining a simulink.paramater to generate #define MACROs in c code using embedded coder? Is there an alternative way other than defining a simulink.paramater to generate #define MACROs in c code using embedded coder? embedded coder, variables MATLAB Answers — New Questions
Index in position 2 exceeds array bounds. Index must not exceed 1.
How to fix errors? "Index in position 2 exceeds array bounds. Index must not exceed 1".
Thanks for everyone’s help
Error in VU_MSSP_2024_QUYDAO (line 72)
Xv_2(s,i+1)=-inv(A_0(4,4))*(A_0(4,1)*Xh(s,i+1)+A_0(4,2)*Xeh(s,i+1)+A_0(4,3)*Xv_1(s,i+1)+A_0(4,5)*Xev_1(s,i+1)+A_0(4,6)*Xev_2(s,i+1)+B_0(4,1)*5*exp(-0.1*(s+i+1))*sin(i+s+1));
clc
clear all;
close all;
I_1=[1];
I_2=[1 0;0 1];
Eh=[1];
Ev=[1 0;0 0];
E=blkdiag(Eh,Ev);
E_c=blkdiag(Eh,Eh,Ev,Ev);
Ih=[1];
Iv=[1 0;0 1];
J=[Ih zeros(1,5);zeros(2,2) Iv zeros(2,2);0 Ih zeros(1,4); zeros(2,2) zeros(2,2) Iv];
A=[0.04 -0.01 0.3;0.01 0.9 0.3;0.15 0.01 -0.05];
H=[-0.02 0.01 0.02;0.05 -0.01 0.05;0.47 0.01 2.02];
C=[0.05 -0.02 0.05;-0.05 0.01 0.08];
B_u=[0.01;0.02;-0.01];
B_w=[-0.02;0.05;0.04];
D_u=[0.05;0.01];
D_w=[0.02;-0.03];
A_c=blkdiag(A,A);
B_wc=[B_w;B_w];
B_c=[B_u -B_u;zeros(3,1) zeros(3,1)];
H_c=[zeros(3,3) zeros(3,3); zeros(3,3) H];
N_E=[zeros(1,6);zeros(1,6);zeros(1,6);1 1 1 1 1 1;zeros(1,6);1 1 1 -1 1 1];
D_1=[D_u -D_u];
%——————–
a=0.8;
gamma=4;
K=[ -0.4957 -9.2860 -4.8612];
L=[ -1726 -1094 43;950 603 -24;-18404 -11652 457];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A_0=J’*[A+B_u*K -B_u*K;zeros(3,3) A-L*H]*J;
B_0=J’*[B_w;B_w];
C_0=[C+D_u*K -D_u*K]*J;
n=80;
v=zeros(1,n);
w=zeros(1,n);
Xh=zeros(n,n); Xeh=zeros(n,n); Xv_1=zeros(n,n);Xv_2=zeros(n,n);Ev_1=zeros(n,n);Xev_2=zeros(n,n);Z=zeros(n,n);U=zeros(n,n);
for i=1:1:n-1
Xh(1,i)=0;
Xeh(1,i)=0;
end
for i=1:1:n-1
Xv_1(i,1)=0;
Xv_2(i,1)=0;
Xev_1(i,1)=0;
Xev_2(i,1)=0;
end
x1=zeros(6,1);x0=zeros(6,1);xc=zeros(6,1);
for i=1:1:n
v(1,i)=i;
w(1,i)=i;
end
for s=1:1:n
for i=1:1:n-1
x0(1,1)=Xh(s,i);x0(2,1)=Xeh(s,i);x0(3,1)=Xv_1(s,i);x0(4,1)=Xv_2(s,i);x0(5,1)=Xev_1(s,i);x0(6,1)=Xev_2(s,i);
x1=A_0*x0+B_0*5*exp(-0.1*(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*Xev_1(s,i)+A_0(5,6)*Xev_2(s,i)+B_0(5,1)*5*exp(-0.1*(s+i))*sin(i+s);
Xev_2(s,i+1)=-inv(A_0(6,6))*(A_0(6,1)*Xh(s,i+1)+A_0(6,2)*Xeh(s,i+1)+A_0(6,3)*Xv_1(s,i+1)+A_0(6,4)*Xv_2(s,i+1)+A_0(6,5)*Xev_1(s,i+1)+B_0(6,1)*5*exp(-0.1*(s+i+1))*sin(i+s+1));
Z(s,i)=norm(C_0*x0+D_w*5*exp(-0.1*(s+i))*sin(i+s));
U(s,i)=K*([Xh(s,i);Xv_1(s,i);Xv_2(s,i)]-[Xeh(s,i);Xev_1(s,i);Xev_2(s,i)]);
end
end
figure(1)
surf(v,w,Xh)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x^h(i,j)’);
%axis([0 100 0 100 -0.15 0.06])
hold on;
figure(2)
surf(v,w,Xeh)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x_e^h(i,j)’);
%axis([0 100 0 100 -0.5 0.1])
hold on;
figure(3)
surf(v,w,Xv_1)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x_1^v(i,j)’);
hold on;
figure(4)
surf(v,w,Xv_2)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x_2^v(i,j)’);
hold on;
figure(5)
surf(v,w,Xev_1)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x_{e1}^v(i,j)’);
hold on;
figure(6)
surf(v,w,Xev_2)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x_{e2}^v(i,j)’);
%axis([0 100 0 100 -0.8 0.2])
hold on;
figure(7)
surf(v,w,Z)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘||z(i,j)||’);
%axis([0 100 0 100 -0.8 0.2])
hold on;
figure(8)
surf(v,w,U)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘u(i,j)|’);
%axis([0 100 0 100 -0.8 0.2])
hold on;
"How to fix errors? "Index in position 2 exceeds array bounds. Index must not exceed 1".
Thanks for everyone’s help
Error in VU_MSSP_2024_QUYDAO (line 72)
Xv_2(s,i+1)=-inv(A_0(4,4))*(A_0(4,1)*Xh(s,i+1)+A_0(4,2)*Xeh(s,i+1)+A_0(4,3)*Xv_1(s,i+1)+A_0(4,5)*Xev_1(s,i+1)+A_0(4,6)*Xev_2(s,i+1)+B_0(4,1)*5*exp(-0.1*(s+i+1))*sin(i+s+1));
clc
clear all;
close all;
I_1=[1];
I_2=[1 0;0 1];
Eh=[1];
Ev=[1 0;0 0];
E=blkdiag(Eh,Ev);
E_c=blkdiag(Eh,Eh,Ev,Ev);
Ih=[1];
Iv=[1 0;0 1];
J=[Ih zeros(1,5);zeros(2,2) Iv zeros(2,2);0 Ih zeros(1,4); zeros(2,2) zeros(2,2) Iv];
A=[0.04 -0.01 0.3;0.01 0.9 0.3;0.15 0.01 -0.05];
H=[-0.02 0.01 0.02;0.05 -0.01 0.05;0.47 0.01 2.02];
C=[0.05 -0.02 0.05;-0.05 0.01 0.08];
B_u=[0.01;0.02;-0.01];
B_w=[-0.02;0.05;0.04];
D_u=[0.05;0.01];
D_w=[0.02;-0.03];
A_c=blkdiag(A,A);
B_wc=[B_w;B_w];
B_c=[B_u -B_u;zeros(3,1) zeros(3,1)];
H_c=[zeros(3,3) zeros(3,3); zeros(3,3) H];
N_E=[zeros(1,6);zeros(1,6);zeros(1,6);1 1 1 1 1 1;zeros(1,6);1 1 1 -1 1 1];
D_1=[D_u -D_u];
%——————–
a=0.8;
gamma=4;
K=[ -0.4957 -9.2860 -4.8612];
L=[ -1726 -1094 43;950 603 -24;-18404 -11652 457];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A_0=J’*[A+B_u*K -B_u*K;zeros(3,3) A-L*H]*J;
B_0=J’*[B_w;B_w];
C_0=[C+D_u*K -D_u*K]*J;
n=80;
v=zeros(1,n);
w=zeros(1,n);
Xh=zeros(n,n); Xeh=zeros(n,n); Xv_1=zeros(n,n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(s,i)+A_0(3,3)*Xv_1(s,i)+A_0(3,4)*Xv_2(s,i)+A_0(3,5)*Xev_1(s,i)+A_0(3,6)*Xev_2(s,i)+B_0(3,1)*5*exp(-0.1*(s+i))*sin(i+s);
Xv_2(s,i+1)=-inv(A_0(4,4))*(A_0(4,1)*Xh(s,i+1)+A_0(4,2)*Xeh(s,i+1)+A_0(4,3)*Xv_1(s,i+1)+A_0(4,5)*Xev_1(s,i+1)+A_0(4,6)*Xev_2(s,i+1)+B_0(4,1)*5*exp(-0.1*(s+i+1))*sin(i+s+1));
Xev_1(s,i+1)=A_0(5,1)*Xh(s,i)+A_0(5,2)*Xeh(s,i)+A_0(5,3)*Xv_1(s,i)+A_0(5,4)*Xv_2(s,i)+A_0(5,5)*Xev_1(s,i)+A_0(5,6)*Xev_2(s,i)+B_0(5,1)*5*exp(-0.1*(s+i))*sin(i+s);
Xev_2(s,i+1)=-inv(A_0(6,6))*(A_0(6,1)*Xh(s,i+1)+A_0(6,2)*Xeh(s,i+1)+A_0(6,3)*Xv_1(s,i+1)+A_0(6,4)*Xv_2(s,i+1)+A_0(6,5)*Xev_1(s,i+1)+B_0(6,1)*5*exp(-0.1*(s+i+1))*sin(i+s+1));
Z(s,i)=norm(C_0*x0+D_w*5*exp(-0.1*(s+i))*sin(i+s));
U(s,i)=K*([Xh(s,i);Xv_1(s,i);Xv_2(s,i)]-[Xeh(s,i);Xev_1(s,i);Xev_2(s,i)]);
end
end
figure(1)
surf(v,w,Xh)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x^h(i,j)’);
%axis([0 100 0 100 -0.15 0.06])
hold on;
figure(2)
surf(v,w,Xeh)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x_e^h(i,j)’);
%axis([0 100 0 100 -0.5 0.1])
hold on;
figure(3)
surf(v,w,Xv_1)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x_1^v(i,j)’);
hold on;
figure(4)
surf(v,w,Xv_2)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x_2^v(i,j)’);
hold on;
figure(5)
surf(v,w,Xev_1)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x_{e1}^v(i,j)’);
hold on;
figure(6)
surf(v,w,Xev_2)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x_{e2}^v(i,j)’);
%axis([0 100 0 100 -0.8 0.2])
hold on;
figure(7)
surf(v,w,Z)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘||z(i,j)||’);
%axis([0 100 0 100 -0.8 0.2])
hold on;
figure(8)
surf(v,w,U)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘u(i,j)|’);
%axis([0 100 0 100 -0.8 0.2])
hold on;
" How to fix errors? "Index in position 2 exceeds array bounds. Index must not exceed 1".
Thanks for everyone’s help
Error in VU_MSSP_2024_QUYDAO (line 72)
Xv_2(s,i+1)=-inv(A_0(4,4))*(A_0(4,1)*Xh(s,i+1)+A_0(4,2)*Xeh(s,i+1)+A_0(4,3)*Xv_1(s,i+1)+A_0(4,5)*Xev_1(s,i+1)+A_0(4,6)*Xev_2(s,i+1)+B_0(4,1)*5*exp(-0.1*(s+i+1))*sin(i+s+1));
clc
clear all;
close all;
I_1=[1];
I_2=[1 0;0 1];
Eh=[1];
Ev=[1 0;0 0];
E=blkdiag(Eh,Ev);
E_c=blkdiag(Eh,Eh,Ev,Ev);
Ih=[1];
Iv=[1 0;0 1];
J=[Ih zeros(1,5);zeros(2,2) Iv zeros(2,2);0 Ih zeros(1,4); zeros(2,2) zeros(2,2) Iv];
A=[0.04 -0.01 0.3;0.01 0.9 0.3;0.15 0.01 -0.05];
H=[-0.02 0.01 0.02;0.05 -0.01 0.05;0.47 0.01 2.02];
C=[0.05 -0.02 0.05;-0.05 0.01 0.08];
B_u=[0.01;0.02;-0.01];
B_w=[-0.02;0.05;0.04];
D_u=[0.05;0.01];
D_w=[0.02;-0.03];
A_c=blkdiag(A,A);
B_wc=[B_w;B_w];
B_c=[B_u -B_u;zeros(3,1) zeros(3,1)];
H_c=[zeros(3,3) zeros(3,3); zeros(3,3) H];
N_E=[zeros(1,6);zeros(1,6);zeros(1,6);1 1 1 1 1 1;zeros(1,6);1 1 1 -1 1 1];
D_1=[D_u -D_u];
%——————–
a=0.8;
gamma=4;
K=[ -0.4957 -9.2860 -4.8612];
L=[ -1726 -1094 43;950 603 -24;-18404 -11652 457];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A_0=J’*[A+B_u*K -B_u*K;zeros(3,3) A-L*H]*J;
B_0=J’*[B_w;B_w];
C_0=[C+D_u*K -D_u*K]*J;
n=80;
v=zeros(1,n);
w=zeros(1,n);
Xh=zeros(n,n); Xeh=zeros(n,n); Xv_1=zeros(n,n);Xv_2=zeros(n,n);Ev_1=zeros(n,n);Xev_2=zeros(n,n);Z=zeros(n,n);U=zeros(n,n);
for i=1:1:n-1
Xh(1,i)=0;
Xeh(1,i)=0;
end
for i=1:1:n-1
Xv_1(i,1)=0;
Xv_2(i,1)=0;
Xev_1(i,1)=0;
Xev_2(i,1)=0;
end
x1=zeros(6,1);x0=zeros(6,1);xc=zeros(6,1);
for i=1:1:n
v(1,i)=i;
w(1,i)=i;
end
for s=1:1:n
for i=1:1:n-1
x0(1,1)=Xh(s,i);x0(2,1)=Xeh(s,i);x0(3,1)=Xv_1(s,i);x0(4,1)=Xv_2(s,i);x0(5,1)=Xev_1(s,i);x0(6,1)=Xev_2(s,i);
x1=A_0*x0+B_0*5*exp(-0.1*(s+i))*sin(i+s);
Xh(s+1,i)=A_0(1,1)*Xh(s,i)+A_0(1,2)*Xeh(s,i)+A_0(1,3)*Xv_1(s,i)+A_0(1,4)*Xv_2(s,i)+A_0(1,5)*Xev_1(s,i)+A_0(1,6)*Xev_2(s,i)+B_0(1,1)*5*exp(-0.1*(s+i))*sin(i+s);
Xeh(s+1,i)=A_0(2,1)*Xh(s,i)+A_0(2,2)*Xeh(s,i)+A_0(2,3)*Xv_1(s,i)+A_0(2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_0*x0+D_w*5*exp(-0.1*(s+i))*sin(i+s));
U(s,i)=K*([Xh(s,i);Xv_1(s,i);Xv_2(s,i)]-[Xeh(s,i);Xev_1(s,i);Xev_2(s,i)]);
end
end
figure(1)
surf(v,w,Xh)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x^h(i,j)’);
%axis([0 100 0 100 -0.15 0.06])
hold on;
figure(2)
surf(v,w,Xeh)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x_e^h(i,j)’);
%axis([0 100 0 100 -0.5 0.1])
hold on;
figure(3)
surf(v,w,Xv_1)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x_1^v(i,j)’);
hold on;
figure(4)
surf(v,w,Xv_2)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x_2^v(i,j)’);
hold on;
figure(5)
surf(v,w,Xev_1)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x_{e1}^v(i,j)’);
hold on;
figure(6)
surf(v,w,Xev_2)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘x_{e2}^v(i,j)’);
%axis([0 100 0 100 -0.8 0.2])
hold on;
figure(7)
surf(v,w,Z)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘||z(i,j)||’);
%axis([0 100 0 100 -0.8 0.2])
hold on;
figure(8)
surf(v,w,U)
xlabel(‘i’);
ylabel(‘j’);
zlabel(‘u(i,j)|’);
%axis([0 100 0 100 -0.8 0.2])
hold on;
" index exceeds array bounds. MATLAB Answers — New Questions
mcb_pmsm_foc_sensorless_f28027LaunchPad
mcb_pmsm_foc_sensorless_f28027LaunchPad Why is the default pi of the model so significant? I directly used the pi parameters set by the hardware, burned them directly, and found that the speed fluctuation was large through PMSM FOC Host control. Do you have a detailed introduction to this model? Just startedmcb_pmsm_foc_sensorless_f28027LaunchPad Why is the default pi of the model so significant? I directly used the pi parameters set by the hardware, burned them directly, and found that the speed fluctuation was large through PMSM FOC Host control. Do you have a detailed introduction to this model? Just started mcb_pmsm_foc_sensorless_f28027LaunchPad Why is the default pi of the model so significant? I directly used the pi parameters set by the hardware, burned them directly, and found that the speed fluctuation was large through PMSM FOC Host control. Do you have a detailed introduction to this model? Just started pi c2000 MATLAB Answers — New Questions
Spreadsheet can not be insert or delete or clear content
I have a daily updated spreadsheet recent found can not do insert row or column, can not delete cell and clear content, and can not do auto calculate, all these without pop up a prompt, just no reaction, but if copy and paste the formula then press enter the calculation still work, these are really bothers me. I am sure this spreadsheet is not locked or with maximum rows or columns
I have a daily updated spreadsheet recent found can not do insert row or column, can not delete cell and clear content, and can not do auto calculate, all these without pop up a prompt, just no reaction, but if copy and paste the formula then press enter the calculation still work, these are really bothers me. I am sure this spreadsheet is not locked or with maximum rows or columns Read More
In Diagnostic Feature Designer, how can I change the color for each signal in plot?
I encountered a weird problem when trying the example in
Analyze and Select Features for Pump Diagnostics – MATLAB & Simulink (mathworks.com)
In this manual, each signal is plot using a quite distinct color, like the examples below:
However, in my MATLAB, what I got is like below, that is all signals use very similar colors:
I there anybody knows what is wrong here?
Or, how to set the colormap or color each signal using distinct colors in Diagnostic Feature Designer?I encountered a weird problem when trying the example in
Analyze and Select Features for Pump Diagnostics – MATLAB & Simulink (mathworks.com)
In this manual, each signal is plot using a quite distinct color, like the examples below:
However, in my MATLAB, what I got is like below, that is all signals use very similar colors:
I there anybody knows what is wrong here?
Or, how to set the colormap or color each signal using distinct colors in Diagnostic Feature Designer? I encountered a weird problem when trying the example in
Analyze and Select Features for Pump Diagnostics – MATLAB & Simulink (mathworks.com)
In this manual, each signal is plot using a quite distinct color, like the examples below:
However, in my MATLAB, what I got is like below, that is all signals use very similar colors:
I there anybody knows what is wrong here?
Or, how to set the colormap or color each signal using distinct colors in Diagnostic Feature Designer? diagnostic feature designer, colormap MATLAB Answers — New Questions
Trying to use an S- Function to run an LCD display with an I2C interface on Ardiuno
I have been trying to interface my Arduino Mega2560 with a 20×4 LCD display. I need to connect it to other systems in Simulink so I read on a different forum one of the best ways to do this was through an S function block. I used the I2C LCD library from https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library to run my function on the Arduino IDE, so I am pretty sure the function is not the problem. One of the issues I cannot seem to solve is that the library for the I2C requires the Wire.h library and I have been unable to find a download for this.
The function in C++ I am trying to call in the S function is:
#include "DispFCN.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
char unit_string[10];
char Disp_string[50];
LiquidCrystal_I2C lcd(0x27, 20, 4);
void DispFCN(int dataWhole, int dataDeci, int unit_ID) {
// The First step is to identify the type of unit by its ID
if (unit_ID == 1) {
sprintf(unit_string, "m/s");
} // This ID denotes windspeed
else if (unit_ID == 2) {
sprintf(unit_string, "F");
} // This ID denotes Temperature in F
sprintf(Disp_string, "%d.%d %s", A, B, unit_string);
// Print a message to the LCD.
lcd.backlight();
lcd.setCursor(1, 0);
lcd.print("Wind Velocity:");
lcd.setCursor(1, 1);
lcd.print(Disp_string);
}
Below is the way that I setup the S function:
The procedure that I was following to build the S function is based off of what was recommended in: https://www.youtube.com/watch?v=L86n9wZZz-g
I have a number of thoughts as to why it is not working, but the error from Simulink seems to imply that I need a version of Wire.h for the I2C LCD library to work, but I cannot find a copy of the Wire.h file to give to Matlab, so I am not sure what I need to do to get the S function to work.I have been trying to interface my Arduino Mega2560 with a 20×4 LCD display. I need to connect it to other systems in Simulink so I read on a different forum one of the best ways to do this was through an S function block. I used the I2C LCD library from https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library to run my function on the Arduino IDE, so I am pretty sure the function is not the problem. One of the issues I cannot seem to solve is that the library for the I2C requires the Wire.h library and I have been unable to find a download for this.
The function in C++ I am trying to call in the S function is:
#include "DispFCN.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
char unit_string[10];
char Disp_string[50];
LiquidCrystal_I2C lcd(0x27, 20, 4);
void DispFCN(int dataWhole, int dataDeci, int unit_ID) {
// The First step is to identify the type of unit by its ID
if (unit_ID == 1) {
sprintf(unit_string, "m/s");
} // This ID denotes windspeed
else if (unit_ID == 2) {
sprintf(unit_string, "F");
} // This ID denotes Temperature in F
sprintf(Disp_string, "%d.%d %s", A, B, unit_string);
// Print a message to the LCD.
lcd.backlight();
lcd.setCursor(1, 0);
lcd.print("Wind Velocity:");
lcd.setCursor(1, 1);
lcd.print(Disp_string);
}
Below is the way that I setup the S function:
The procedure that I was following to build the S function is based off of what was recommended in: https://www.youtube.com/watch?v=L86n9wZZz-g
I have a number of thoughts as to why it is not working, but the error from Simulink seems to imply that I need a version of Wire.h for the I2C LCD library to work, but I cannot find a copy of the Wire.h file to give to Matlab, so I am not sure what I need to do to get the S function to work. I have been trying to interface my Arduino Mega2560 with a 20×4 LCD display. I need to connect it to other systems in Simulink so I read on a different forum one of the best ways to do this was through an S function block. I used the I2C LCD library from https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library to run my function on the Arduino IDE, so I am pretty sure the function is not the problem. One of the issues I cannot seem to solve is that the library for the I2C requires the Wire.h library and I have been unable to find a download for this.
The function in C++ I am trying to call in the S function is:
#include "DispFCN.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
char unit_string[10];
char Disp_string[50];
LiquidCrystal_I2C lcd(0x27, 20, 4);
void DispFCN(int dataWhole, int dataDeci, int unit_ID) {
// The First step is to identify the type of unit by its ID
if (unit_ID == 1) {
sprintf(unit_string, "m/s");
} // This ID denotes windspeed
else if (unit_ID == 2) {
sprintf(unit_string, "F");
} // This ID denotes Temperature in F
sprintf(Disp_string, "%d.%d %s", A, B, unit_string);
// Print a message to the LCD.
lcd.backlight();
lcd.setCursor(1, 0);
lcd.print("Wind Velocity:");
lcd.setCursor(1, 1);
lcd.print(Disp_string);
}
Below is the way that I setup the S function:
The procedure that I was following to build the S function is based off of what was recommended in: https://www.youtube.com/watch?v=L86n9wZZz-g
I have a number of thoughts as to why it is not working, but the error from Simulink seems to imply that I need a version of Wire.h for the I2C LCD library to work, but I cannot find a copy of the Wire.h file to give to Matlab, so I am not sure what I need to do to get the S function to work. sfunctions, simulink, matlab, lcd, i2c, iic MATLAB Answers — New Questions
Dev Channel update to 127.0.2651.8 is live.
Hello Insiders! We released 127.0.2651.8 to the Dev channel! Mac also released with a version bump 128.0.2650.0!
The release includes numerous fixes. For more details on the changes, check out the highlights below.
An even faster Microsoft Edge – Microsoft Edge Blog (windows.com)
Added Features:
Introduced a ‘Learn More’ feature within the translation settings toggle.
Improved Reliability:
Fixed an issue causing a crash when a local tab group was deleted.
Resolved an issue that caused the browser to crash when the Fullscreen button was clicked on a YouTube video.
Fixed an issue that caused the browser to crash when submitting feedback.
Changed Behavior:
Resolved an issue where restarting the browser caused grouped tabs to be displayed as URLs instead of their respective tab names.
Resolved an issue that caused a workspace to open with all tab groups unfolded, despite being closed in the previous session.
Resolved an issue to ensure the expanded or collapsed state of a tab group is saved within a workspace.
Fixed an issue where changing the tab orientation would leave the menu open but remove the active state from the Tab action menu button.
Fixed an issue where the tab key did not allow for the selection of an item or folder downwards in the favorites hub.
Mac: The problem where hovering over the Copilot icon caused all app icons to become unresponsive has been fixed on mac.
iOS:
Resolved an issue where the user interface for the search results displayed through the search function was inaccurate on iOS.
Resolved an issue resulting in the Read Aloud toolbar not displaying all its content fully on iOS.
Android:
The issue of a toolbar appearing on the New Tab Page (NTP) on Android has been resolved.
The issue where two translation columns appeared after using the ‘Find on page’ feature following a translation has been resolved.
See an issue that you think might be a bug? Remember to send that directly through the in-app feedback by heading to the … menu > Help and feedback > Send feedback and include diagnostics so the team can investigate.
Thanks again for sending us feedback and helping us improve our Insider builds.
~Gouri
Hello Insiders! We released 127.0.2651.8 to the Dev channel! Mac also released with a version bump 128.0.2650.0!
The release includes numerous fixes. For more details on the changes, check out the highlights below.
An even faster Microsoft Edge – Microsoft Edge Blog (windows.com)
Added Features:
Introduced a ‘Learn More’ feature within the translation settings toggle.
Improved Reliability:
Fixed an issue causing a crash when a local tab group was deleted.
Resolved an issue that caused the browser to crash when the Fullscreen button was clicked on a YouTube video.
Fixed an issue that caused the browser to crash when submitting feedback.
Changed Behavior:
Resolved an issue where restarting the browser caused grouped tabs to be displayed as URLs instead of their respective tab names.
Resolved an issue that caused a workspace to open with all tab groups unfolded, despite being closed in the previous session.
Resolved an issue to ensure the expanded or collapsed state of a tab group is saved within a workspace.
Fixed an issue where changing the tab orientation would leave the menu open but remove the active state from the Tab action menu button.
Fixed an issue where the tab key did not allow for the selection of an item or folder downwards in the favorites hub.
Mac: The problem where hovering over the Copilot icon caused all app icons to become unresponsive has been fixed on mac.
iOS:
Resolved an issue where the user interface for the search results displayed through the search function was inaccurate on iOS.
Resolved an issue resulting in the Read Aloud toolbar not displaying all its content fully on iOS.
Android:
The issue of a toolbar appearing on the New Tab Page (NTP) on Android has been resolved.
The issue where two translation columns appeared after using the ‘Find on page’ feature following a translation has been resolved.
See an issue that you think might be a bug? Remember to send that directly through the in-app feedback by heading to the … menu > Help and feedback > Send feedback and include diagnostics so the team can investigate.
Thanks again for sending us feedback and helping us improve our Insider builds.
~Gouri Read More
Não consigo resgatar recompensas.
Não estou conseguindo resgatar no Microsoft Rewards, aparece uma mensagem quando vou fazer o resgate para adicionar um número de telefone e sou redirecionado para os Alias da conta. Lá eu coloco meu número corretamente porém recebo uma mensagem que diz “Tente outro método de verificação” e embaixo diz “Esse método de verificação não está funcionando no momento. Tente outro método” mas ja está assim desde abril desse ano!
Não estou conseguindo resgatar no Microsoft Rewards, aparece uma mensagem quando vou fazer o resgate para adicionar um número de telefone e sou redirecionado para os Alias da conta. Lá eu coloco meu número corretamente porém recebo uma mensagem que diz “Tente outro método de verificação” e embaixo diz “Esse método de verificação não está funcionando no momento. Tente outro método” mas ja está assim desde abril desse ano! Read More
How to track when status change?
Hello,
I have a column set to display “New” when a new request comes in. Another user will then update the status to either “Pending,” “Cancelled,” or “Confirmed.” I want to track how long it takes for the status to change ex. from “New” to “Confirmed.” The goal is generate a report for auditing purpose.
Thank you!!
Hello, I would like to know if there is a way to track when a status is changed on SharePoint. For example:I have a column set to display “New” when a new request comes in. Another user will then update the status to either “Pending,” “Cancelled,” or “Confirmed.” I want to track how long it takes for the status to change ex. from “New” to “Confirmed.” The goal is generate a report for auditing purpose. Thank you!! Read More
OneDrive app bug
There are bugs in OneDrive Mac App (24.111.0602). The first bug is I cannot scroll the files sync on OneDrive App located at the status bar (upper right hand corner). The second bug is when I click the preference icon nothing happens.
There are bugs in OneDrive Mac App (24.111.0602). The first bug is I cannot scroll the files sync on OneDrive App located at the status bar (upper right hand corner). The second bug is when I click the preference icon nothing happens. Read More