Month: July 2025
Anonymous function handle incosistence problem with Fourier functions
Hello, during some optics simulation I dared to shorten my code (a .m type) by making fourier transform an anonymous function as such:
F = @(x) fftshift(fft(ifftshift(x)));
iF = @(x) ifftshift(ifft(fftshift(x)));
poow = @(x) abs(x).^ 2;
with these I would Transform, inverse transform and Find the intensity of the signal but for a reason I don’t know it only works when I post it in the command window… sometimes.
here is an example of it in action:
L = 15; % mm
F = 100; % mm
f0 = 1/100e-3; % lp/mm
f1 = 1/300e-3; % lp/mm
dx = 4e-3; % mm
t = 0:dx:L-dx; % mm
n = length(t);
f = -1/(2*dx):1/L:(1/(2*dx)-1/L);
object = chirp(t,f0,t(end),f1,"quadratic");
I = poow(object);
%% transform the object and display
object_ = F(object);
I_object_ = poow(object_);
Now, the problem is as you might see here is that the error this time is:
Array indices must be positive integers or logical values.
but on my machine its:
Error: File: LiveEditorEvaluationHelperE1735339498.m Line: 57 Column: 7
Invalid expression. Check for missing or extra characters.
Error in LiveEditorEvaluationHelperE1735339498>@(x)fftshift(fft(ifftshift(x))) (line 3)
F = @(x) fftshift(fft(ifftshift(x)));
^
this error happens to all previewed anonymous functions.
I have checked if a simpler handle would work and it does only crash when calling these 3 specific ones when running the script.Hello, during some optics simulation I dared to shorten my code (a .m type) by making fourier transform an anonymous function as such:
F = @(x) fftshift(fft(ifftshift(x)));
iF = @(x) ifftshift(ifft(fftshift(x)));
poow = @(x) abs(x).^ 2;
with these I would Transform, inverse transform and Find the intensity of the signal but for a reason I don’t know it only works when I post it in the command window… sometimes.
here is an example of it in action:
L = 15; % mm
F = 100; % mm
f0 = 1/100e-3; % lp/mm
f1 = 1/300e-3; % lp/mm
dx = 4e-3; % mm
t = 0:dx:L-dx; % mm
n = length(t);
f = -1/(2*dx):1/L:(1/(2*dx)-1/L);
object = chirp(t,f0,t(end),f1,"quadratic");
I = poow(object);
%% transform the object and display
object_ = F(object);
I_object_ = poow(object_);
Now, the problem is as you might see here is that the error this time is:
Array indices must be positive integers or logical values.
but on my machine its:
Error: File: LiveEditorEvaluationHelperE1735339498.m Line: 57 Column: 7
Invalid expression. Check for missing or extra characters.
Error in LiveEditorEvaluationHelperE1735339498>@(x)fftshift(fft(ifftshift(x))) (line 3)
F = @(x) fftshift(fft(ifftshift(x)));
^
this error happens to all previewed anonymous functions.
I have checked if a simpler handle would work and it does only crash when calling these 3 specific ones when running the script. Hello, during some optics simulation I dared to shorten my code (a .m type) by making fourier transform an anonymous function as such:
F = @(x) fftshift(fft(ifftshift(x)));
iF = @(x) ifftshift(ifft(fftshift(x)));
poow = @(x) abs(x).^ 2;
with these I would Transform, inverse transform and Find the intensity of the signal but for a reason I don’t know it only works when I post it in the command window… sometimes.
here is an example of it in action:
L = 15; % mm
F = 100; % mm
f0 = 1/100e-3; % lp/mm
f1 = 1/300e-3; % lp/mm
dx = 4e-3; % mm
t = 0:dx:L-dx; % mm
n = length(t);
f = -1/(2*dx):1/L:(1/(2*dx)-1/L);
object = chirp(t,f0,t(end),f1,"quadratic");
I = poow(object);
%% transform the object and display
object_ = F(object);
I_object_ = poow(object_);
Now, the problem is as you might see here is that the error this time is:
Array indices must be positive integers or logical values.
but on my machine its:
Error: File: LiveEditorEvaluationHelperE1735339498.m Line: 57 Column: 7
Invalid expression. Check for missing or extra characters.
Error in LiveEditorEvaluationHelperE1735339498>@(x)fftshift(fft(ifftshift(x))) (line 3)
F = @(x) fftshift(fft(ifftshift(x)));
^
this error happens to all previewed anonymous functions.
I have checked if a simpler handle would work and it does only crash when calling these 3 specific ones when running the script. fft, ifft, fftshift, ifftshift, anonymous function, fourier MATLAB Answers — New Questions
MATLAB R2025a won’t start after uninstalling R2023a
I recently installed Matlab R2025a on my PC with Windows 11 and it worked perfectly. But after I uninstalled R2023a, R2025a won’t launch. The launch screen just takes forever to display. The uninstallation of R2023a was done through Settings-Apps-Installed apps-MATALB R2023a-Uninstall, which was completed successfully. I tried to uninstall R2025a in a similar way but failed. After I clicked "yes" to the prompt "Do you want to allow this app to make changes to your device", nothing happened. I also tried running C:Program FilesMATLABR2025abinwin64MathWorksProductUninstaller.exe in terminal, and afater I clicked "yes’ nothing happened. Then I tried installing R2025a, but couldn’t continue as it said it’s already installed. Now I’m stuck, not able to launch/uninstall/re-install R2025a.
Any advice, please? Thank you.I recently installed Matlab R2025a on my PC with Windows 11 and it worked perfectly. But after I uninstalled R2023a, R2025a won’t launch. The launch screen just takes forever to display. The uninstallation of R2023a was done through Settings-Apps-Installed apps-MATALB R2023a-Uninstall, which was completed successfully. I tried to uninstall R2025a in a similar way but failed. After I clicked "yes" to the prompt "Do you want to allow this app to make changes to your device", nothing happened. I also tried running C:Program FilesMATLABR2025abinwin64MathWorksProductUninstaller.exe in terminal, and afater I clicked "yes’ nothing happened. Then I tried installing R2025a, but couldn’t continue as it said it’s already installed. Now I’m stuck, not able to launch/uninstall/re-install R2025a.
Any advice, please? Thank you. I recently installed Matlab R2025a on my PC with Windows 11 and it worked perfectly. But after I uninstalled R2023a, R2025a won’t launch. The launch screen just takes forever to display. The uninstallation of R2023a was done through Settings-Apps-Installed apps-MATALB R2023a-Uninstall, which was completed successfully. I tried to uninstall R2025a in a similar way but failed. After I clicked "yes" to the prompt "Do you want to allow this app to make changes to your device", nothing happened. I also tried running C:Program FilesMATLABR2025abinwin64MathWorksProductUninstaller.exe in terminal, and afater I clicked "yes’ nothing happened. Then I tried installing R2025a, but couldn’t continue as it said it’s already installed. Now I’m stuck, not able to launch/uninstall/re-install R2025a.
Any advice, please? Thank you. r2025a, uninstallation, won’t launch MATLAB Answers — New Questions
having error while running fuzzy controller and fuzzy set of matlab 2017 in matlab 2023?
2 inputs and 1 output with mamdani rule.2 inputs and 1 output with mamdani rule. 2 inputs and 1 output with mamdani rule. fuzzy, matlab MATLAB Answers — New Questions
Nice to have – function output argument provide code assist when said function is called
This is a feature which doesn’t apear to currently exist, but I think alot of matlab users would like, particularly ones who write alot of custom classes.
Imagine i have a custom class with some properties:
classdef CustomClass < handle
properties
name (1,1) string = "default name"
varOne (1,1) double = 0
end
methods
function obj = CustomClass(name,varOne)
obj.name = name;
obj.VarOne = varOne;
end
end
end
Then imagine I have a function which returns one of these custom class objects:
function [obj] = Calculation(Var1,Var2,name)
arguments (Input)
Var1 (1,1) double
Var2 (1,1) double
end
arguments (Output)
obj (1,1) CustomClass
end
results = Var1 + Var2;
obj = CustomClass(name,result);
end
With this class and this function which returns one of these class objects, I would like the fact that I provided "(1,1) CustomClass" in the output arguemnts block of function "Calculation(Var1,Var2,name)" to trigger code assist automaticaly show me, when writing code that the retuned value from this funciton has properties "name" and "varOne" in the object.
For istance, if I write the following code with this function and the class in the Matlab search path
testObj = Calculation(1,1,"test");
testObj.varOne = 10; %the property "varOne" doesn’t apear in code assist when writing this line of code
I would like that the fact function "Calcuation(Var1,Var2,name) has the output arguments block enforcing that this function must return an object of "CustomClass" to make code assist recognise that "testObj" is a "CustomClass" object, just as if testObj was an input argument to another function which had an input argument requiring that "testObj" was a "CustomClass" object.
Maybe this is a feature that may be added to matlab in future releases? (please and thank you LOL)This is a feature which doesn’t apear to currently exist, but I think alot of matlab users would like, particularly ones who write alot of custom classes.
Imagine i have a custom class with some properties:
classdef CustomClass < handle
properties
name (1,1) string = "default name"
varOne (1,1) double = 0
end
methods
function obj = CustomClass(name,varOne)
obj.name = name;
obj.VarOne = varOne;
end
end
end
Then imagine I have a function which returns one of these custom class objects:
function [obj] = Calculation(Var1,Var2,name)
arguments (Input)
Var1 (1,1) double
Var2 (1,1) double
end
arguments (Output)
obj (1,1) CustomClass
end
results = Var1 + Var2;
obj = CustomClass(name,result);
end
With this class and this function which returns one of these class objects, I would like the fact that I provided "(1,1) CustomClass" in the output arguemnts block of function "Calculation(Var1,Var2,name)" to trigger code assist automaticaly show me, when writing code that the retuned value from this funciton has properties "name" and "varOne" in the object.
For istance, if I write the following code with this function and the class in the Matlab search path
testObj = Calculation(1,1,"test");
testObj.varOne = 10; %the property "varOne" doesn’t apear in code assist when writing this line of code
I would like that the fact function "Calcuation(Var1,Var2,name) has the output arguments block enforcing that this function must return an object of "CustomClass" to make code assist recognise that "testObj" is a "CustomClass" object, just as if testObj was an input argument to another function which had an input argument requiring that "testObj" was a "CustomClass" object.
Maybe this is a feature that may be added to matlab in future releases? (please and thank you LOL) This is a feature which doesn’t apear to currently exist, but I think alot of matlab users would like, particularly ones who write alot of custom classes.
Imagine i have a custom class with some properties:
classdef CustomClass < handle
properties
name (1,1) string = "default name"
varOne (1,1) double = 0
end
methods
function obj = CustomClass(name,varOne)
obj.name = name;
obj.VarOne = varOne;
end
end
end
Then imagine I have a function which returns one of these custom class objects:
function [obj] = Calculation(Var1,Var2,name)
arguments (Input)
Var1 (1,1) double
Var2 (1,1) double
end
arguments (Output)
obj (1,1) CustomClass
end
results = Var1 + Var2;
obj = CustomClass(name,result);
end
With this class and this function which returns one of these class objects, I would like the fact that I provided "(1,1) CustomClass" in the output arguemnts block of function "Calculation(Var1,Var2,name)" to trigger code assist automaticaly show me, when writing code that the retuned value from this funciton has properties "name" and "varOne" in the object.
For istance, if I write the following code with this function and the class in the Matlab search path
testObj = Calculation(1,1,"test");
testObj.varOne = 10; %the property "varOne" doesn’t apear in code assist when writing this line of code
I would like that the fact function "Calcuation(Var1,Var2,name) has the output arguments block enforcing that this function must return an object of "CustomClass" to make code assist recognise that "testObj" is a "CustomClass" object, just as if testObj was an input argument to another function which had an input argument requiring that "testObj" was a "CustomClass" object.
Maybe this is a feature that may be added to matlab in future releases? (please and thank you LOL) matlab, class MATLAB Answers — New Questions
Entra ID Introduces Linkable Token Identifiers for Audit Events
Identifier Makes it Easier to Track User Activities in a Single Session
An interesting July 21 Technical Community announcement describes the introduction of linkable token identifiers for audit events. Essentially, when a user authenticates a session with Entra ID, the session is stamped with a unique GUID (the linkable token identifier). The linkable token identifier is persistent for the session and is inherited by workloads that support the token and inserted into the audit events generated by those workloads accessed during the session.
The idea is that by tracing the linkable token identifier, you can find out what the user did during a session. Linking audit events through the new identifier makes it easier for investigators to query audit data to discover the set of actions taken during a session and their sequencing. This might be necessary to check if an attacker has compromised an account and is exfiltrating data or taking other actions that you don’t want to happen. Of course, account compromise is less likely to happen when user accounts are protected with strong multifactor authentication like the Microsoft Authenticator app, but that’s another story.
The linkable token identifiers are now available in Entra sign-in logs, Exchange Online audit events, SharePoint Online audit events, Teams audit events, and Graph activity logs. Figure 1 shows the identifiers listed in the Entra sign-in log.

Using Audit Searches to Track Activities
Audit events end up in the unified audit log and the article includes a screen shot showing the results of a search using a linked token identifier. Unhappily, the article doesn’t explain that you must use a keyword search to find events linked to a certain identifier (Figure 2).

The reason why a keyword (free text) search is necessary is that workload developers are inconsistent in how they include linkable token identifiers in the AuditData payload of their events. As you’d expect, Entra ID includes a simple SessionId property in the payload, but other workloads like Exchange Online and SharePoint Online refer to the token as AADSessionId.
Finding and Reporting Activities Based on Identifiers
Which brings me to subject of how to search the audit log with PowerShell for all events with a linkable token identifier. The process is reasonably simple. For example, using the Search-UnifiedAuditLog cmdlet, the code is something like this:
[array]$Records = Search-UnifiedAuditLog -Formatted -StartDate $StartDate -EndDate (Get-Date) -UserIds $UserId -FreeText $Session -SessionCommand ReturnLargeSet -ResultSize 5000 If ($Records.Count -eq 0) { Write-Host "No audit records found for session $Session" Continue } Else { $Records = $Records | Sort-Object Identity -Unique $Records = $Records | Sort-Object {$_.CreationDate -as [datetime]} Write-Host ("Found {0} audit records for session {1}" -f $Records.Count, $Session) }
Reporting Audit Events for All Sessions
The code uses a free text search to find all audit events that include the specified linkable token identifier between two dates, removes any duplicates events from the returned set, and sorts the set by the created date.
But how about extending this to generate a report for all events for all sessions within the 30-day period that Entra ID retains sign-in logs. After all, multiple sessions might be created around the same time, and only one of the sessions might be suspicious. To do this, we need to find the full set of sign-in events captured for a user and find the linkable token identifiers in that set. Here’s how to find that information using the Get-MgBetaAuditLogSignIn cmdlet from the Microsoft Graph PowerShell SDK (the beta cmdlet is needed to return the identifiers):
[array]$Logs = Get-MgBetaAuditLogSignIn -Filter "userPrincipalName eq 'lotte.vetler@office365itpros.com'" -All [array]$Sessions = $Logs | Group-Object SessionId -NoElement | Select-Object -ExpandProperty Name
The $Sessions array now contains the linkable token identifiers, and to generate the report, it’s a matter of looping through the set of identifiers to use each with Search-UnifiedAuditLog to generate the set of audit events for the session. Figure 3 shows the kind of report that can be created from the generated data.

The code I used to create the report is available for download from the Office 365 for IT Pros GitHub repository. In addition to the HTML report, the script also generates a CSV or XLSX file (an Excel worksheet is created if the ImportExcel module is available).
Good for Investigators
I’m sure that investigators will appreciate being able to easily connect the dots to discover what happened during a session. Adding linkable token identifiers to audit events is an example of a low-touch, high-value enhancement for Microsoft 365 tenants. It would be nice if all updates had the same impact.
Need some assistance to write and manage PowerShell scripts for Microsoft 365? Get a copy of the Automating Microsoft 365 with PowerShell eBook, available standalone or as part of the Office 365 for IT Pros eBook bundle.
Compiler ignores MCC options
Dear,
Since I updated to r2025a, I’m encountering issues with the compiler.build.standaloneWindowsApplication method.
In the buildOpts struct I parse to this function, I specify `AdditionalFiles`, but they are not included in the build (nor in the compiled package).
I did some debugging on the builder, and both builder.MccInfo.MccInput as builder.MccInfo.MccCommandString show the Additional files correctly, but once premcc, mcc and postmcc are called, the files are never added to the `FilesToBeDeployed` array (except the icon, splashscreen, and executable).
It seems to be that MCC is ignoring the input commands it receives. With r2024b, this issue did not exist, and the AdditionalFiles were added succesfully at each compile.
How can I fix this?
Best Regards,
JelleDear,
Since I updated to r2025a, I’m encountering issues with the compiler.build.standaloneWindowsApplication method.
In the buildOpts struct I parse to this function, I specify `AdditionalFiles`, but they are not included in the build (nor in the compiled package).
I did some debugging on the builder, and both builder.MccInfo.MccInput as builder.MccInfo.MccCommandString show the Additional files correctly, but once premcc, mcc and postmcc are called, the files are never added to the `FilesToBeDeployed` array (except the icon, splashscreen, and executable).
It seems to be that MCC is ignoring the input commands it receives. With r2024b, this issue did not exist, and the AdditionalFiles were added succesfully at each compile.
How can I fix this?
Best Regards,
Jelle Dear,
Since I updated to r2025a, I’m encountering issues with the compiler.build.standaloneWindowsApplication method.
In the buildOpts struct I parse to this function, I specify `AdditionalFiles`, but they are not included in the build (nor in the compiled package).
I did some debugging on the builder, and both builder.MccInfo.MccInput as builder.MccInfo.MccCommandString show the Additional files correctly, but once premcc, mcc and postmcc are called, the files are never added to the `FilesToBeDeployed` array (except the icon, splashscreen, and executable).
It seems to be that MCC is ignoring the input commands it receives. With r2024b, this issue did not exist, and the AdditionalFiles were added succesfully at each compile.
How can I fix this?
Best Regards,
Jelle compiler, r2025a MATLAB Answers — New Questions
Material property assignment in electromagnetic solve
In the following scritp I continue to get errors about the material assignemnt.
clear; close all; clc;
% ===== PHYSICAL PARAMETERS =====
lambda = 785e-9; % Wavelength [m]
omega = 2*pi*3e8/lambda; % Angular frequency [rad/s]
eps0 = 8.8541878128e-12; % Vacuum permittivity [F/m]
% ===== MATERIAL PROPERTIES =====
eps_au = (-24.051 + 1.3i) + 25; % Gold permittivity (shifted to Re(ε)>0)
eps_sio2 = 2.25; % SiO2 relative permittivity
% ===== CREATE MODEL =====
model = createpde(‘electromagnetic’,’harmonic’);
model.VacuumPermittivity = eps0;
% ===== GEOMETRY DEFINITION =====
% SiO2 substrate (500nm x 100nm)
rect_sio2 = [3;4; 0;500e-9;500e-9;0; 0;0;100e-9;100e-9];
% Air gap (500nm x 5nm, starting at y=100nm)
gap_y_start = 100e-9;
gap_height = 5e-9;
rect_air = [3;4; 0;500e-9;500e-9;0; …
gap_y_start+1e-12; gap_y_start+1e-12; … % Slightly offset to avoid overlap
gap_y_start+gap_height-1e-12; gap_y_start+gap_height-1e-12];
% Gold nanoparticle (radius 50nm at x=250nm, y=149nm)
circ = [1;250e-9;149e-9;50e-9; zeros(6,1)];
% Combine geometry with constructive solid geometry
gd = [rect_sio2, rect_air, circ];
ns = char(‘sio2′,’airgap’,’gold’)’;
sf = ‘(sio2 + airgap) + gold’; % Proper CSG formula
dl = decsg(gd,sf,ns);
geometryFromEdges(model, dl);
% ===== VISUALIZE FACE LABELS (CRUCIAL STEP) =====
figure;
pdegplot(model,’FaceLabels’,’on’,’EdgeLabels’,’on’);
title(‘Geometry Face Labels’);
axis equal;
% ===== MATERIAL ASSIGNMENT =====
% Assign properties based on face numbers from plot
% NOTE: Face numbers may differ – adjust based on pdegplot output!
electromagneticProperties(model,’Face’,1,’RelativePermittivity’,eps_sio2,…
‘RelativePermeability’,1,’Conductivity’,0); % SiO2
electromagneticProperties(model,’Face’,2,’RelativePermittivity’,1,…
‘RelativePermeability’,1,’Conductivity’,0); % Air
electromagneticProperties(model,’Face’,3,’RelativePermittivity’,eps_au,…
‘RelativePermeability’,1,’Conductivity’,0); % Gold
% ===== BOUNDARY CONDITIONS =====
k_spp = 2*pi/lambda * sqrt(eps_au/(1 + eps_au));
jsFun = @(location,~) exp(1i * k_spp * location.x);
electromagneticBC(model,’Edge’,1,’SurfaceCurrentDensity’,jsFun); % SPP excitation
electromagneticBC(model,’Edge’,[2,4],’FarField’,’absorbing’,…
‘Thickness’,lambda/4); % Absorbing BCs
% ===== MESH GENERATION =====
generateMesh(model,…
‘Hmax’,lambda/20, …
‘Hmin’,gap_height/2, …
‘Hgrad’,1.3, …
‘GeometricOrder’,’linear’);
figure;
pdemesh(model);
title(‘Mesh’);
axis equal;
% ===== SOLVE & VISUALIZE =====
result = solve(model,’Frequency’,omega);
E = result.ElectricField;
Emag = sqrt(abs(E.Ex).^2 + abs(E.Ey).^2 + abs(E.Ez).^2);
figure;
pdeplot(model,’XYData’,Emag,’ColorMap’,’jet’,’Mesh’,’off’);
title(‘Electric Field Magnitude |E|’);
colorbar;
axis equal;In the following scritp I continue to get errors about the material assignemnt.
clear; close all; clc;
% ===== PHYSICAL PARAMETERS =====
lambda = 785e-9; % Wavelength [m]
omega = 2*pi*3e8/lambda; % Angular frequency [rad/s]
eps0 = 8.8541878128e-12; % Vacuum permittivity [F/m]
% ===== MATERIAL PROPERTIES =====
eps_au = (-24.051 + 1.3i) + 25; % Gold permittivity (shifted to Re(ε)>0)
eps_sio2 = 2.25; % SiO2 relative permittivity
% ===== CREATE MODEL =====
model = createpde(‘electromagnetic’,’harmonic’);
model.VacuumPermittivity = eps0;
% ===== GEOMETRY DEFINITION =====
% SiO2 substrate (500nm x 100nm)
rect_sio2 = [3;4; 0;500e-9;500e-9;0; 0;0;100e-9;100e-9];
% Air gap (500nm x 5nm, starting at y=100nm)
gap_y_start = 100e-9;
gap_height = 5e-9;
rect_air = [3;4; 0;500e-9;500e-9;0; …
gap_y_start+1e-12; gap_y_start+1e-12; … % Slightly offset to avoid overlap
gap_y_start+gap_height-1e-12; gap_y_start+gap_height-1e-12];
% Gold nanoparticle (radius 50nm at x=250nm, y=149nm)
circ = [1;250e-9;149e-9;50e-9; zeros(6,1)];
% Combine geometry with constructive solid geometry
gd = [rect_sio2, rect_air, circ];
ns = char(‘sio2′,’airgap’,’gold’)’;
sf = ‘(sio2 + airgap) + gold’; % Proper CSG formula
dl = decsg(gd,sf,ns);
geometryFromEdges(model, dl);
% ===== VISUALIZE FACE LABELS (CRUCIAL STEP) =====
figure;
pdegplot(model,’FaceLabels’,’on’,’EdgeLabels’,’on’);
title(‘Geometry Face Labels’);
axis equal;
% ===== MATERIAL ASSIGNMENT =====
% Assign properties based on face numbers from plot
% NOTE: Face numbers may differ – adjust based on pdegplot output!
electromagneticProperties(model,’Face’,1,’RelativePermittivity’,eps_sio2,…
‘RelativePermeability’,1,’Conductivity’,0); % SiO2
electromagneticProperties(model,’Face’,2,’RelativePermittivity’,1,…
‘RelativePermeability’,1,’Conductivity’,0); % Air
electromagneticProperties(model,’Face’,3,’RelativePermittivity’,eps_au,…
‘RelativePermeability’,1,’Conductivity’,0); % Gold
% ===== BOUNDARY CONDITIONS =====
k_spp = 2*pi/lambda * sqrt(eps_au/(1 + eps_au));
jsFun = @(location,~) exp(1i * k_spp * location.x);
electromagneticBC(model,’Edge’,1,’SurfaceCurrentDensity’,jsFun); % SPP excitation
electromagneticBC(model,’Edge’,[2,4],’FarField’,’absorbing’,…
‘Thickness’,lambda/4); % Absorbing BCs
% ===== MESH GENERATION =====
generateMesh(model,…
‘Hmax’,lambda/20, …
‘Hmin’,gap_height/2, …
‘Hgrad’,1.3, …
‘GeometricOrder’,’linear’);
figure;
pdemesh(model);
title(‘Mesh’);
axis equal;
% ===== SOLVE & VISUALIZE =====
result = solve(model,’Frequency’,omega);
E = result.ElectricField;
Emag = sqrt(abs(E.Ex).^2 + abs(E.Ey).^2 + abs(E.Ez).^2);
figure;
pdeplot(model,’XYData’,Emag,’ColorMap’,’jet’,’Mesh’,’off’);
title(‘Electric Field Magnitude |E|’);
colorbar;
axis equal; In the following scritp I continue to get errors about the material assignemnt.
clear; close all; clc;
% ===== PHYSICAL PARAMETERS =====
lambda = 785e-9; % Wavelength [m]
omega = 2*pi*3e8/lambda; % Angular frequency [rad/s]
eps0 = 8.8541878128e-12; % Vacuum permittivity [F/m]
% ===== MATERIAL PROPERTIES =====
eps_au = (-24.051 + 1.3i) + 25; % Gold permittivity (shifted to Re(ε)>0)
eps_sio2 = 2.25; % SiO2 relative permittivity
% ===== CREATE MODEL =====
model = createpde(‘electromagnetic’,’harmonic’);
model.VacuumPermittivity = eps0;
% ===== GEOMETRY DEFINITION =====
% SiO2 substrate (500nm x 100nm)
rect_sio2 = [3;4; 0;500e-9;500e-9;0; 0;0;100e-9;100e-9];
% Air gap (500nm x 5nm, starting at y=100nm)
gap_y_start = 100e-9;
gap_height = 5e-9;
rect_air = [3;4; 0;500e-9;500e-9;0; …
gap_y_start+1e-12; gap_y_start+1e-12; … % Slightly offset to avoid overlap
gap_y_start+gap_height-1e-12; gap_y_start+gap_height-1e-12];
% Gold nanoparticle (radius 50nm at x=250nm, y=149nm)
circ = [1;250e-9;149e-9;50e-9; zeros(6,1)];
% Combine geometry with constructive solid geometry
gd = [rect_sio2, rect_air, circ];
ns = char(‘sio2′,’airgap’,’gold’)’;
sf = ‘(sio2 + airgap) + gold’; % Proper CSG formula
dl = decsg(gd,sf,ns);
geometryFromEdges(model, dl);
% ===== VISUALIZE FACE LABELS (CRUCIAL STEP) =====
figure;
pdegplot(model,’FaceLabels’,’on’,’EdgeLabels’,’on’);
title(‘Geometry Face Labels’);
axis equal;
% ===== MATERIAL ASSIGNMENT =====
% Assign properties based on face numbers from plot
% NOTE: Face numbers may differ – adjust based on pdegplot output!
electromagneticProperties(model,’Face’,1,’RelativePermittivity’,eps_sio2,…
‘RelativePermeability’,1,’Conductivity’,0); % SiO2
electromagneticProperties(model,’Face’,2,’RelativePermittivity’,1,…
‘RelativePermeability’,1,’Conductivity’,0); % Air
electromagneticProperties(model,’Face’,3,’RelativePermittivity’,eps_au,…
‘RelativePermeability’,1,’Conductivity’,0); % Gold
% ===== BOUNDARY CONDITIONS =====
k_spp = 2*pi/lambda * sqrt(eps_au/(1 + eps_au));
jsFun = @(location,~) exp(1i * k_spp * location.x);
electromagneticBC(model,’Edge’,1,’SurfaceCurrentDensity’,jsFun); % SPP excitation
electromagneticBC(model,’Edge’,[2,4],’FarField’,’absorbing’,…
‘Thickness’,lambda/4); % Absorbing BCs
% ===== MESH GENERATION =====
generateMesh(model,…
‘Hmax’,lambda/20, …
‘Hmin’,gap_height/2, …
‘Hgrad’,1.3, …
‘GeometricOrder’,’linear’);
figure;
pdemesh(model);
title(‘Mesh’);
axis equal;
% ===== SOLVE & VISUALIZE =====
result = solve(model,’Frequency’,omega);
E = result.ElectricField;
Emag = sqrt(abs(E.Ex).^2 + abs(E.Ey).^2 + abs(E.Ez).^2);
figure;
pdeplot(model,’XYData’,Emag,’ColorMap’,’jet’,’Mesh’,’off’);
title(‘Electric Field Magnitude |E|’);
colorbar;
axis equal; pde, electromagnetic model, properties MATLAB Answers — New Questions
Issue transposing a matrix inside of a timeseries
Hello everyone,
Im trying to transpose a matrix defined inside of a timeseries:
Rk = timeseries(parentDataset.reflectometry.density’, parentDataset.reflectometry.time);
parentDataset.reflectometry.density is a 7×1 matrix that I need to transpose to become 1×7 however its returning a 1x1x7. I tried using squeeze, reshape or permute to no avail.
I also tried transposing the matrix before feeding it inside the timeseries but I’m also meeting the same issue.
What really confuses me is that when parentDataset.reflectometry.density is a 1×7, transposing it actually returns a 7×1 matrix (and returns 2 when checking wiht ndims).
How can i fix this? And what am I misunderstnading?
Thanks for any help!Hello everyone,
Im trying to transpose a matrix defined inside of a timeseries:
Rk = timeseries(parentDataset.reflectometry.density’, parentDataset.reflectometry.time);
parentDataset.reflectometry.density is a 7×1 matrix that I need to transpose to become 1×7 however its returning a 1x1x7. I tried using squeeze, reshape or permute to no avail.
I also tried transposing the matrix before feeding it inside the timeseries but I’m also meeting the same issue.
What really confuses me is that when parentDataset.reflectometry.density is a 1×7, transposing it actually returns a 7×1 matrix (and returns 2 when checking wiht ndims).
How can i fix this? And what am I misunderstnading?
Thanks for any help! Hello everyone,
Im trying to transpose a matrix defined inside of a timeseries:
Rk = timeseries(parentDataset.reflectometry.density’, parentDataset.reflectometry.time);
parentDataset.reflectometry.density is a 7×1 matrix that I need to transpose to become 1×7 however its returning a 1x1x7. I tried using squeeze, reshape or permute to no avail.
I also tried transposing the matrix before feeding it inside the timeseries but I’m also meeting the same issue.
What really confuses me is that when parentDataset.reflectometry.density is a 1×7, transposing it actually returns a 7×1 matrix (and returns 2 when checking wiht ndims).
How can i fix this? And what am I misunderstnading?
Thanks for any help! matlab MATLAB Answers — New Questions
Details pane missing in 2025a
I have just installed 2025a and the details pane in the main command window is missing. I can’t find the setting to restore it. It’s reall y useful to load single variables from mat files and add other variables so I really miss it! Attached image shows it in 2024bI have just installed 2025a and the details pane in the main command window is missing. I can’t find the setting to restore it. It’s reall y useful to load single variables from mat files and add other variables so I really miss it! Attached image shows it in 2024b I have just installed 2025a and the details pane in the main command window is missing. I can’t find the setting to restore it. It’s reall y useful to load single variables from mat files and add other variables so I really miss it! Attached image shows it in 2024b details pane, r2025a complaints MATLAB Answers — New Questions
Adding external files to Matlab Compiler app in R2025a
Unfortunately I had to upgrade to R2025a recently and have been hugely disppointed by what seems like a massive regression in the app compiling workflow using Matlab Compiler. In R2024a, which I was using before, I was confident I could have got my app packaged up in 15 minutes, with R2025a I’ve been battling with it for over a day and still finding it troublesome. Has anyone else had experience using this on a complex project?
This huge change is not adequately covered in Release Notes nor in product help, but now you have to have a Matlab project in order to compile using the app. I’ve never used projects before (they seemed to offer nothing for our work style) so already this was a big change. But they have serious restrictions compared to past versions too.
It seems to accept code not being under the project folder no problem, which is a relief as I have a large repository of code that is used and I can’t put it all under a project directory. However, I also use dlls, some icons, etc and in the past I could simply add these to the ‘Files required for your application to run’ section of the compiler. They would end up in the exact same relative location on the user’s machine so my functions that use relative paths to read them worked fine in deployed apps too.
But now, in R2025 the ‘Custom requirements’ section of ‘Files required for Standalone to run’ insists on any file that is added being under the project folder. This means I have to take a copy of dlls, icons, etc and put them there. But these files get unpacked to a completely different location on the target machine, so any code that expects these to exist in a certain relative folder location breaks.
I can use ctfroot to take me to the parent folder where the app is deployed, but not the specific app folder under that, so I have to search around under that folder to find my dlls in some subfolder.
This is a fundamental change from R2024a and I am very disappointed by such a massive regression in the workflow. Matlab has always been excellent at backwards compatibility in almost every area, but this has made what used to be a relatively efficient process into something that is a struggle to make work at all.Unfortunately I had to upgrade to R2025a recently and have been hugely disppointed by what seems like a massive regression in the app compiling workflow using Matlab Compiler. In R2024a, which I was using before, I was confident I could have got my app packaged up in 15 minutes, with R2025a I’ve been battling with it for over a day and still finding it troublesome. Has anyone else had experience using this on a complex project?
This huge change is not adequately covered in Release Notes nor in product help, but now you have to have a Matlab project in order to compile using the app. I’ve never used projects before (they seemed to offer nothing for our work style) so already this was a big change. But they have serious restrictions compared to past versions too.
It seems to accept code not being under the project folder no problem, which is a relief as I have a large repository of code that is used and I can’t put it all under a project directory. However, I also use dlls, some icons, etc and in the past I could simply add these to the ‘Files required for your application to run’ section of the compiler. They would end up in the exact same relative location on the user’s machine so my functions that use relative paths to read them worked fine in deployed apps too.
But now, in R2025 the ‘Custom requirements’ section of ‘Files required for Standalone to run’ insists on any file that is added being under the project folder. This means I have to take a copy of dlls, icons, etc and put them there. But these files get unpacked to a completely different location on the target machine, so any code that expects these to exist in a certain relative folder location breaks.
I can use ctfroot to take me to the parent folder where the app is deployed, but not the specific app folder under that, so I have to search around under that folder to find my dlls in some subfolder.
This is a fundamental change from R2024a and I am very disappointed by such a massive regression in the workflow. Matlab has always been excellent at backwards compatibility in almost every area, but this has made what used to be a relatively efficient process into something that is a struggle to make work at all. Unfortunately I had to upgrade to R2025a recently and have been hugely disppointed by what seems like a massive regression in the app compiling workflow using Matlab Compiler. In R2024a, which I was using before, I was confident I could have got my app packaged up in 15 minutes, with R2025a I’ve been battling with it for over a day and still finding it troublesome. Has anyone else had experience using this on a complex project?
This huge change is not adequately covered in Release Notes nor in product help, but now you have to have a Matlab project in order to compile using the app. I’ve never used projects before (they seemed to offer nothing for our work style) so already this was a big change. But they have serious restrictions compared to past versions too.
It seems to accept code not being under the project folder no problem, which is a relief as I have a large repository of code that is used and I can’t put it all under a project directory. However, I also use dlls, some icons, etc and in the past I could simply add these to the ‘Files required for your application to run’ section of the compiler. They would end up in the exact same relative location on the user’s machine so my functions that use relative paths to read them worked fine in deployed apps too.
But now, in R2025 the ‘Custom requirements’ section of ‘Files required for Standalone to run’ insists on any file that is added being under the project folder. This means I have to take a copy of dlls, icons, etc and put them there. But these files get unpacked to a completely different location on the target machine, so any code that expects these to exist in a certain relative folder location breaks.
I can use ctfroot to take me to the parent folder where the app is deployed, but not the specific app folder under that, so I have to search around under that folder to find my dlls in some subfolder.
This is a fundamental change from R2024a and I am very disappointed by such a massive regression in the workflow. Matlab has always been excellent at backwards compatibility in almost every area, but this has made what used to be a relatively efficient process into something that is a struggle to make work at all. compiler, projects MATLAB Answers — New Questions
How to Remove Members from Microsoft 365 Groups with PowerShell
Removing Members from Groups Can be Complicated
Recently, I discussed how to use Microsoft Graph PowerShell SDK cmdlets to copy the memberships of Entra ID groups from one user to another. I commented that in some cases you might want to remove the memberships for the source user but left that code to the reader to develop and incorporate into the script.
Within an hour of publication, I received a couple of messages asking how to remove users from group memberships. It’s a fair question because the cmdlets used for the task differ across group types. Specifically:
- For Microsoft 365 and security groups, use the Remove-MgGroupMemberByRef cmdlet from the Microsoft Graph PowerShell SDK. At least, that’s the facile answer. As explained below, the real answer is more complicated.
- For distribution lists and mail-enabled security groups, use the Remove-DistributionGroupMember cmdlet from the Exchange Online management module.
Some ask why the membership of mail-enabled security groups is managed using Exchange cmdlets. The answer lies in the mail-enabled nature of these groups. Because they are mail-enabled, their source directory is the Exchange ExODS (Exchange Online Directory Store) rather than Entra ID. Synchronization and dual-write updates keep the two directories in step.
In any case, removing a user account from a distribution list or mail-enabled security group is straightforward:
Remove-DistributionGroupMember -Identity $GroupId -Member $UserId -Confirm:$false -ErrorAction Stop Write-Host ("User {0} removed from distribution list {1}" -f $TargetDisplayName, $GroupDisplayName) -ForegroundColor Yellow
Why Things are More Complicated with Microsoft 365 Groups
Because of the need to respect how group ownership works, things are a little more complex with Microsoft 365 groups, including the groups used for Teams, and Viva Engage. The rules are:
- If you remove a member, you must check if the account is a group owner. If so, you remove the group owner first and then remove the member.
- However, if the account is the only group owner, you can’t remove them because this would leave the group in an ownerless state.
The Microsoft 365 administrative portals don’t permit the removal of the last owner and insist that groups have at least one owner. It’s possible that groups get into an ownerless state if the account of the last owner is deleted. At that point, the groups ownership governance policy can attempt to find a new owner (if the tenant has Entra P1 licenses) or you can write a PowerShell script to look for a new owner.
Code to Remove Members from Microsoft 365 Groups
The logic for removing a group member is therefore:
- Use the Get-MgGroupOwner cmdlet to fetch the set of group owners and check the set to see if the member being deleted is a group owner.
- If yes, and the number of owners is one, exit.
- If yes, and more than one owner exists, run the Remove-MgGroupOwnerByRef cmdlet to remove the owner first and then run the Remove-MgGroupMemberByRef cmdlet to remove the member.
The usual approach for this kind of processing is to create a function, so here’s an example of a function that takes the user identifier, group identifier, and group display name as parameters (the latter is purely for output purposes) to process the removal of a user account from a Microsoft 365 group or security group:
function Remove-UserFromM365Group { # Remove a user account from a Microsoft 365 group, checking if the user is an owner first. # If the user is an owner and they are not the last owner, # the function removes the user from as both an owner and a member of the group. param ( [Parameter(Mandatory = $true)] [string]$UserId, [Parameter(Mandatory = $true)] [string]$GroupId, [Parameter(Mandatory = $true)] [string]$GroupName ) $Outcome = $null [array]$Owners = Get-MgGroupOwner -GroupId $GroupId | Select-Object -ExpandProperty Id if ($UserId -in $Owners) { if ($Owners.count -eq 1) { Write-Host ("The {0} group has only one owner - can't remove the last owner" -f $GroupDisplayName) -Foregroundcolor Red $Outcome = "Failed - can't remove the last owner of a group" return $Outcome } Write-Host ("User {0} is an owner of group {1} - removing both owner and member links" -f $TargetDisplayName, $GroupDisplayName) -ForegroundColor Yellow try { Remove-MgGroupOwnerByRef -DirectoryObjectId $UserId -GroupId $GroupId } catch { Write-Host ("Failed to remove user {0} as owner from group {1}: {2}" -f $TargetDisplayName, $GroupDisplayName, $_.Exception.Message) -ForegroundColor Red $Outcome = "Failed to remove owner" return $Outcome } } try { Remove-MgGroupMemberByRef -DirectoryObjectId $UserId -GroupId $GroupId } catch { Write-Host ("Failed to remove user {0} as member from group {1}: {2}" -f $TargetDisplayName, $GroupDisplayName, $_.Exception.Message) -ForegroundColor Red $Outcome = "Failed to remove member" return $Outcome } $Outcome = ("User {0} removed from group {1}" -f $SourceDisplayName, $GroupDIsplayName) return $Outcome }
Better PowerShell developers than I could probably tidy the function, but the code works and demonstrates the principles behind removing members from a Microsoft 365 group (or security group), which is what I set out to do. I’ve updated the original script in GitHub, and you can download the complete code from the Office 365 for IT Pros repository.
Figure 1 shows how to run the script, specifying a source account, a target account, and a Boolean parameter controlling whether to remove the transferred memberships from the source account.

Removing Members from Groups Requires Knowledge
The question about removing group memberships is a great example of why it’s important to understand the technology and how Microsoft 365 really works before attempting to automate operations. Many blogs give partial answers. Without knowledge, you can’t fill in the gaps to create a complete answer, which is why we have the Office 365 for IT Pros eBook including the companion Automating Microsoft 365 PowerShell eBook.
Need some assistance to write and manage PowerShell scripts for Microsoft 365? Get a copy of the Automating Microsoft 365 with PowerShell eBook, available standalone or as part of the Office 365 for IT Pros eBook bundle.
Wrong number of Edges/Faces after .stl-Import with fegeometry
When I create a femodel-Object from an existing .stl-file, some edges/faces get lost and I don’t know how/why/where. My original 3D-model looks like this:
However, when I create the femodel with
geometryFile = ‘Pilz.stl’;
geometryFile = fegeometry(geometryFile);
the edges from two of the four opposite faces tangent to the clyinder part of the mushroom get lost, see below picture:
I need these four faces to apply a FaceLoad later on, but F3 in this case is not just the flat area but also the two rounded faces up to the edge of F1.
I’m guessing it is not a problem with the .stl-file itself, because I’ve varied the width of the flat areas up to the point where the cylinder part is basically a square, but MATLAB still only recognizes 4 faces around the circumference.
How do I get MATLAB or the fegeometry function to recognize the missing Faces like so:?
Thanks in advance!When I create a femodel-Object from an existing .stl-file, some edges/faces get lost and I don’t know how/why/where. My original 3D-model looks like this:
However, when I create the femodel with
geometryFile = ‘Pilz.stl’;
geometryFile = fegeometry(geometryFile);
the edges from two of the four opposite faces tangent to the clyinder part of the mushroom get lost, see below picture:
I need these four faces to apply a FaceLoad later on, but F3 in this case is not just the flat area but also the two rounded faces up to the edge of F1.
I’m guessing it is not a problem with the .stl-file itself, because I’ve varied the width of the flat areas up to the point where the cylinder part is basically a square, but MATLAB still only recognizes 4 faces around the circumference.
How do I get MATLAB or the fegeometry function to recognize the missing Faces like so:?
Thanks in advance! When I create a femodel-Object from an existing .stl-file, some edges/faces get lost and I don’t know how/why/where. My original 3D-model looks like this:
However, when I create the femodel with
geometryFile = ‘Pilz.stl’;
geometryFile = fegeometry(geometryFile);
the edges from two of the four opposite faces tangent to the clyinder part of the mushroom get lost, see below picture:
I need these four faces to apply a FaceLoad later on, but F3 in this case is not just the flat area but also the two rounded faces up to the edge of F1.
I’m guessing it is not a problem with the .stl-file itself, because I’ve varied the width of the flat areas up to the point where the cylinder part is basically a square, but MATLAB still only recognizes 4 faces around the circumference.
How do I get MATLAB or the fegeometry function to recognize the missing Faces like so:?
Thanks in advance! femodel, stl, 3d, edges, mesh MATLAB Answers — New Questions
Clustering using Gower’s Distance
Hello all, I have a dataset that includes both categorical and numerical features, and I’m looking to perform clustering on it. I’ve read that Gower’s Distance (code is available) is suitable for handling mixed data types. However, I am getting an "isnan" error. How can I fix the problem? Thanks for the help.
DataSet = readtable("Test.xlsx", ‘ReadVariableNames’, true);
GowerDst = gower(DataSet);
[Idx, C] = kmedoids(DataSet, 2, ‘Distance’, GowerDst);
Error using isnan
Invalid data type. Argument must be numeric, char, or logical.
Error in kmedoids (line 220)
wasnan = any(isnan(X),2);
^^^^^^^^
Error in Gower_Distance (line 9)
[Idx, C] = kmedoids(DataSet, 2, ‘Distance’, GowerDst);Hello all, I have a dataset that includes both categorical and numerical features, and I’m looking to perform clustering on it. I’ve read that Gower’s Distance (code is available) is suitable for handling mixed data types. However, I am getting an "isnan" error. How can I fix the problem? Thanks for the help.
DataSet = readtable("Test.xlsx", ‘ReadVariableNames’, true);
GowerDst = gower(DataSet);
[Idx, C] = kmedoids(DataSet, 2, ‘Distance’, GowerDst);
Error using isnan
Invalid data type. Argument must be numeric, char, or logical.
Error in kmedoids (line 220)
wasnan = any(isnan(X),2);
^^^^^^^^
Error in Gower_Distance (line 9)
[Idx, C] = kmedoids(DataSet, 2, ‘Distance’, GowerDst); Hello all, I have a dataset that includes both categorical and numerical features, and I’m looking to perform clustering on it. I’ve read that Gower’s Distance (code is available) is suitable for handling mixed data types. However, I am getting an "isnan" error. How can I fix the problem? Thanks for the help.
DataSet = readtable("Test.xlsx", ‘ReadVariableNames’, true);
GowerDst = gower(DataSet);
[Idx, C] = kmedoids(DataSet, 2, ‘Distance’, GowerDst);
Error using isnan
Invalid data type. Argument must be numeric, char, or logical.
Error in kmedoids (line 220)
wasnan = any(isnan(X),2);
^^^^^^^^
Error in Gower_Distance (line 9)
[Idx, C] = kmedoids(DataSet, 2, ‘Distance’, GowerDst); gower’s distance, clustering MATLAB Answers — New Questions
No results from calculations in the command window
Hi there,
For some reason I am not getting any output results in the command window. I click on run and no results appear in the command window from my script. Nor, is there any results in the workspace – even though there a lots of calculations. I have restarted my computer and still there is no change. The last thing I was doing was trying to create a MATLAB function. Also, in the editor tab the option to create a new scipt is faded out. So I can’t access a new script. I have been using MATLAB online for months and I have never experienced this problem or any problem like it.
I am very confused and I do not know what is going wrong!
I hope someone can help?
Many thanks,
ScottHi there,
For some reason I am not getting any output results in the command window. I click on run and no results appear in the command window from my script. Nor, is there any results in the workspace – even though there a lots of calculations. I have restarted my computer and still there is no change. The last thing I was doing was trying to create a MATLAB function. Also, in the editor tab the option to create a new scipt is faded out. So I can’t access a new script. I have been using MATLAB online for months and I have never experienced this problem or any problem like it.
I am very confused and I do not know what is going wrong!
I hope someone can help?
Many thanks,
Scott Hi there,
For some reason I am not getting any output results in the command window. I click on run and no results appear in the command window from my script. Nor, is there any results in the workspace – even though there a lots of calculations. I have restarted my computer and still there is no change. The last thing I was doing was trying to create a MATLAB function. Also, in the editor tab the option to create a new scipt is faded out. So I can’t access a new script. I have been using MATLAB online for months and I have never experienced this problem or any problem like it.
I am very confused and I do not know what is going wrong!
I hope someone can help?
Many thanks,
Scott error, command window MATLAB Answers — New Questions
How to fix: Index Exceeds Matrix Dimensions
clear
clc
clf
%***************************************************
% constants
rad=pi/180;
eps0=8.85e-12;
mu0=4*pi*1e-7;
eta0=sqrt(mu0/eps0); % free space
c=1/sqrt(eps0*mu0);
%***************************************************
% variables
d=2.5e-3; % thickness of the sample
f1=1e9; df=9e6; f2=10e9; Nf=floor((f2-f1)/df)+1; % frequency range and
% load raw data
M1r = csvread(‘sample.dat’,4); % Read the data
P1r = csvread(‘sample1.dat’,2); % Read the data
P2r = csvread(‘sample2.dat’,2); % Read the data
Mag1=M1r(:,2);
Mag2=M1r(:,3);
Ph1=-unwrap(P1r(:,2),180);
Ph2=-unwrap(P2r(:,2),180);
%*****************************************
% freqyency loop begin
for it=1:Nf
f=f1+(it-1)*df;
Fr(it)=f;
Fghz(it)=f/1e9;
fghz=f/1e9;
Z0=eta0; W=2*pi*Fr(it); beta0=W/c;
%*******************************************
% combine magnitude and phase of the S11 and S21
R(it)=Mag1(it)*exp(j*Ph1(it)*rad);………………………………………………..error Index exceeds matrix dimensions.
R(it)=Mag1(it)*exp(j*Ph1(it)*rad);
T(it)=Mag2(it)*exp(j*Ph2(it)*rad);
% m loop begin
Max=0; % ———m value set up
itt=0;
for m=-Max:Max
itt=itt+1;
%***************************************************
% using formulas from Robust method
Tp=T(it);
Z21(it)=sqrt(((1+R(it))^2-Tp^2)/((1-R(it))^2-Tp^2));
Z22(it)=-sqrt(((1+R(it))^2-Tp^2)/((1-R(it))^2-Tp^2));
expinkd1(it)=Tp/(1-R(it)*(Z21(it)-1)/(Z21(it)+1));
expinkd2(it)=Tp/(1-R(it)*(Z22(it)-1)/(Z22(it)+1));
if abs(real(Z21(it)))>=0.005 & real(Z21(it))>=0
expinkd(it)=expinkd1(it);
Z2(it)=Z21(it);
end
if abs(real(Z21(it)))>=0.005 & real(Z21(it))<0
expinkd(it)=expinkd2(it);
Z2(it)=Z22(it);
end
if abs(real(Z21(it)))<0.005 & abs(expinkd1(it))<=1
expinkd(it)=expinkd1(it);
Z2(it)=Z21(it);
end
if abs(real(Z21(it)))<0.005 & abs(expinkd1(it))>1
expinkd(it)=expinkd2(it);
Z2(it)=Z22(it);
end
ni(it)=-1/(beta0*d)*j*real(log(expinkd(it))); % imag of n
nr(it,itt)=1/(beta0*d)*(imag(log(expinkd(it)))+2*m*pi); %real of n
n2(it,itt)=nr(it,itt)+ni(it);
Er2(it,itt)=n2(it,itt)/Z2(it);
Mr2(it,itt)=n2(it,itt)*Z2(it);
end % end of m loop
end % end of frequency loopclear
clc
clf
%***************************************************
% constants
rad=pi/180;
eps0=8.85e-12;
mu0=4*pi*1e-7;
eta0=sqrt(mu0/eps0); % free space
c=1/sqrt(eps0*mu0);
%***************************************************
% variables
d=2.5e-3; % thickness of the sample
f1=1e9; df=9e6; f2=10e9; Nf=floor((f2-f1)/df)+1; % frequency range and
% load raw data
M1r = csvread(‘sample.dat’,4); % Read the data
P1r = csvread(‘sample1.dat’,2); % Read the data
P2r = csvread(‘sample2.dat’,2); % Read the data
Mag1=M1r(:,2);
Mag2=M1r(:,3);
Ph1=-unwrap(P1r(:,2),180);
Ph2=-unwrap(P2r(:,2),180);
%*****************************************
% freqyency loop begin
for it=1:Nf
f=f1+(it-1)*df;
Fr(it)=f;
Fghz(it)=f/1e9;
fghz=f/1e9;
Z0=eta0; W=2*pi*Fr(it); beta0=W/c;
%*******************************************
% combine magnitude and phase of the S11 and S21
R(it)=Mag1(it)*exp(j*Ph1(it)*rad);………………………………………………..error Index exceeds matrix dimensions.
R(it)=Mag1(it)*exp(j*Ph1(it)*rad);
T(it)=Mag2(it)*exp(j*Ph2(it)*rad);
% m loop begin
Max=0; % ———m value set up
itt=0;
for m=-Max:Max
itt=itt+1;
%***************************************************
% using formulas from Robust method
Tp=T(it);
Z21(it)=sqrt(((1+R(it))^2-Tp^2)/((1-R(it))^2-Tp^2));
Z22(it)=-sqrt(((1+R(it))^2-Tp^2)/((1-R(it))^2-Tp^2));
expinkd1(it)=Tp/(1-R(it)*(Z21(it)-1)/(Z21(it)+1));
expinkd2(it)=Tp/(1-R(it)*(Z22(it)-1)/(Z22(it)+1));
if abs(real(Z21(it)))>=0.005 & real(Z21(it))>=0
expinkd(it)=expinkd1(it);
Z2(it)=Z21(it);
end
if abs(real(Z21(it)))>=0.005 & real(Z21(it))<0
expinkd(it)=expinkd2(it);
Z2(it)=Z22(it);
end
if abs(real(Z21(it)))<0.005 & abs(expinkd1(it))<=1
expinkd(it)=expinkd1(it);
Z2(it)=Z21(it);
end
if abs(real(Z21(it)))<0.005 & abs(expinkd1(it))>1
expinkd(it)=expinkd2(it);
Z2(it)=Z22(it);
end
ni(it)=-1/(beta0*d)*j*real(log(expinkd(it))); % imag of n
nr(it,itt)=1/(beta0*d)*(imag(log(expinkd(it)))+2*m*pi); %real of n
n2(it,itt)=nr(it,itt)+ni(it);
Er2(it,itt)=n2(it,itt)/Z2(it);
Mr2(it,itt)=n2(it,itt)*Z2(it);
end % end of m loop
end % end of frequency loop clear
clc
clf
%***************************************************
% constants
rad=pi/180;
eps0=8.85e-12;
mu0=4*pi*1e-7;
eta0=sqrt(mu0/eps0); % free space
c=1/sqrt(eps0*mu0);
%***************************************************
% variables
d=2.5e-3; % thickness of the sample
f1=1e9; df=9e6; f2=10e9; Nf=floor((f2-f1)/df)+1; % frequency range and
% load raw data
M1r = csvread(‘sample.dat’,4); % Read the data
P1r = csvread(‘sample1.dat’,2); % Read the data
P2r = csvread(‘sample2.dat’,2); % Read the data
Mag1=M1r(:,2);
Mag2=M1r(:,3);
Ph1=-unwrap(P1r(:,2),180);
Ph2=-unwrap(P2r(:,2),180);
%*****************************************
% freqyency loop begin
for it=1:Nf
f=f1+(it-1)*df;
Fr(it)=f;
Fghz(it)=f/1e9;
fghz=f/1e9;
Z0=eta0; W=2*pi*Fr(it); beta0=W/c;
%*******************************************
% combine magnitude and phase of the S11 and S21
R(it)=Mag1(it)*exp(j*Ph1(it)*rad);………………………………………………..error Index exceeds matrix dimensions.
R(it)=Mag1(it)*exp(j*Ph1(it)*rad);
T(it)=Mag2(it)*exp(j*Ph2(it)*rad);
% m loop begin
Max=0; % ———m value set up
itt=0;
for m=-Max:Max
itt=itt+1;
%***************************************************
% using formulas from Robust method
Tp=T(it);
Z21(it)=sqrt(((1+R(it))^2-Tp^2)/((1-R(it))^2-Tp^2));
Z22(it)=-sqrt(((1+R(it))^2-Tp^2)/((1-R(it))^2-Tp^2));
expinkd1(it)=Tp/(1-R(it)*(Z21(it)-1)/(Z21(it)+1));
expinkd2(it)=Tp/(1-R(it)*(Z22(it)-1)/(Z22(it)+1));
if abs(real(Z21(it)))>=0.005 & real(Z21(it))>=0
expinkd(it)=expinkd1(it);
Z2(it)=Z21(it);
end
if abs(real(Z21(it)))>=0.005 & real(Z21(it))<0
expinkd(it)=expinkd2(it);
Z2(it)=Z22(it);
end
if abs(real(Z21(it)))<0.005 & abs(expinkd1(it))<=1
expinkd(it)=expinkd1(it);
Z2(it)=Z21(it);
end
if abs(real(Z21(it)))<0.005 & abs(expinkd1(it))>1
expinkd(it)=expinkd2(it);
Z2(it)=Z22(it);
end
ni(it)=-1/(beta0*d)*j*real(log(expinkd(it))); % imag of n
nr(it,itt)=1/(beta0*d)*(imag(log(expinkd(it)))+2*m*pi); %real of n
n2(it,itt)=nr(it,itt)+ni(it);
Er2(it,itt)=n2(it,itt)/Z2(it);
Mr2(it,itt)=n2(it,itt)*Z2(it);
end % end of m loop
end % end of frequency loop index exceeds matrix dimensions. error in check2 (line 37) r(it)=mag1(it)*exp(j*ph1(it)*rad) MATLAB Answers — New Questions
Be Careful with Retention Labels Configured with Created Date Expiration
Older Files With Long Retention Periods Might Disappear Unexpectedly
Microsoft introduced retention policies and retention labels as part of its Office 365 Data Governance Framework in April 2017. These components are part of the Purview Data Lifecycle Management solution now. Capabilities have evolved a lot since 2017 in areas like special auto-label policies for “cloudy” attachments, disposition reviews, and the use of trainable classifiers, but the basics remain the same. Retention policies or retention labels track how old items are and when those items reach a threshold, a retention action happens. Often, the action is to delete the item.
Which brings me to a puzzling experience I had a few weeks ago when spreadsheets that I use to track various topics disappeared. The items that I noticed all came from my OneDrive for Business account, and when I checked there, I found the items in the first stage recycle bin. The question was what action moved the items into the recycle bin.
Old Retention Labels Might Have Simple Settings
The answer was simple. When Microsoft introduced retention labels and policies, I created a batch of labels and started to use them to manage content. At the time, things were simpler, and retention operated on creation date. Today, you can choose for retention to operate on the basis of the last modified date, which is the setting I use in more recently-created retention labels. Monitoring the last modified date is better because it means that files that remain in active use are not removed by retention processing, which is probably what you want.
The retention label applied to the disappeared files had a long retention period (Figure 1) but counted the retention period from the created date. It just so happened that all the files that ended up in the recycle bin were created in early 2015 and had therefore reached the end of the retention period. The next time Purview processed OneDrive, it duly noted the fact and took the retention action to move the files into the recycle bin.

Mystery Solved
The mystery of why my files suddenly disappeared from view was solved, but there’s a serious lesson to be learned here. It is quite likely that other Microsoft 365 tenants have retention policies or labels that operate on a “when created” rather than “last modified” basis. Checking the created date for files is very effective at clearing out old material but falls down when that material, although old, is still in active use.
The problem is that you can’t simply update a retention label to change its retention settings. You can change the retention period to increase or decrease the number of days for Purview to retain an item, but you cannot change “when created” to “last modified.” Increasing the retention period is a pragmatic way to solve the immediate problem, but it means that some files that should be removed will stay around for longer, and that’s a bad thing in an era when AI tools cheerfully consume even the oldest and most outdated information to generate responses.
A better long-term solution is to replace old retention labels with updated versions that use the last modified date. This article explains how to use the Get-MgDriveItemRetentionLabel cmdlet from the Microsoft Graph PowerShell SDK to read the retention label applied to files and the Update-MgDriveItemRetentionLabel to apply a replacement label (the same cmdlet can apply a default retention label to a folder). Another Practical365.com article looks at some of the business reasons why it might be necessary to replace retention labels on files, including a script to do the job.
Solving the Problem in Code
In my case, I took the script I wrote to report files stored in a OneDrive for Business account and ran it to identify what retention labels are applied to files in OneDrive. I then created a replacement retention label with the same retention period but with modified date as the test for retention. Finally, I copied the reporting script and modified the function that reads retention label data to look for the label (or labels) to replace and called the Update-MgDriveItemRetentionLabel cmdlet to assign the new label. You can download the script from the Office 365 for IT Pros GitHub repository.
Unfortunately, the gods of scripting (or APIs) intervened and the underlying Graph API developed a problem when updating labels. The same issue surfaced in the SharePoint PnP module. I’ve reported the problem and hope that Microsoft solve the issue soon. In the meantime, I updated the retention labels manually for several important files to make sure that Purview wouldn’t remove them. It’s disappointing that the script doesn’t work at present, but it will in the future.
Insight like this doesn’t come easily. You’ve got to know the technology and understand how to look behind the scenes. Benefit from the knowledge and experience of the Office 365 for IT Pros team by subscribing to the best eBook covering Office 365 and the wider Microsoft 365 ecosystem.
Matlab freezes on startup
Hello all ,Matlab freezes on startup. It opens a file named dos.m, and from that point, I can neither run any script, set the path, nor even navigate to a folder. any idea ?Hello all ,Matlab freezes on startup. It opens a file named dos.m, and from that point, I can neither run any script, set the path, nor even navigate to a folder. any idea ? Hello all ,Matlab freezes on startup. It opens a file named dos.m, and from that point, I can neither run any script, set the path, nor even navigate to a folder. any idea ? transferred MATLAB Answers — New Questions
Dictionary to std::unordered_map in a mex file
I am using some c++ code with mex. I would like to pass in a dictionary of parameters, do some computation and create some vectors, and then return the results as a dictionary. Something like the following:
// test_mex.cpp
#include "mex.h"
void mexFunction(int N_output, mxArray *output[], int N_input, const mxArray *input[]) {
// Check input
if (N_input != 1) {
mexErrMsgIdAndTxt("MyClass:InvalidInput", "One input required.");
}
if (!mxIsClass(input[0], "dictionary")) {
mexErrMsgIdAndTxt("MATLAB:invalidInput", "Input must be a dictionary.");
}
// Convert to a std::unordered_map
std::unordered_map<std::string, double> params = input[0];
// Compute
std::unordered_map<std::string, std::vector<double>> out;
out["C"] = std::vector<double>(params["A"], 1.0);
// Convert back to a dictionary and return
output[0] = out;
}
Called with:
mex test_mex; test_mex(dictionary(["A", "B"], {100, 1020}));I am using some c++ code with mex. I would like to pass in a dictionary of parameters, do some computation and create some vectors, and then return the results as a dictionary. Something like the following:
// test_mex.cpp
#include "mex.h"
void mexFunction(int N_output, mxArray *output[], int N_input, const mxArray *input[]) {
// Check input
if (N_input != 1) {
mexErrMsgIdAndTxt("MyClass:InvalidInput", "One input required.");
}
if (!mxIsClass(input[0], "dictionary")) {
mexErrMsgIdAndTxt("MATLAB:invalidInput", "Input must be a dictionary.");
}
// Convert to a std::unordered_map
std::unordered_map<std::string, double> params = input[0];
// Compute
std::unordered_map<std::string, std::vector<double>> out;
out["C"] = std::vector<double>(params["A"], 1.0);
// Convert back to a dictionary and return
output[0] = out;
}
Called with:
mex test_mex; test_mex(dictionary(["A", "B"], {100, 1020})); I am using some c++ code with mex. I would like to pass in a dictionary of parameters, do some computation and create some vectors, and then return the results as a dictionary. Something like the following:
// test_mex.cpp
#include "mex.h"
void mexFunction(int N_output, mxArray *output[], int N_input, const mxArray *input[]) {
// Check input
if (N_input != 1) {
mexErrMsgIdAndTxt("MyClass:InvalidInput", "One input required.");
}
if (!mxIsClass(input[0], "dictionary")) {
mexErrMsgIdAndTxt("MATLAB:invalidInput", "Input must be a dictionary.");
}
// Convert to a std::unordered_map
std::unordered_map<std::string, double> params = input[0];
// Compute
std::unordered_map<std::string, std::vector<double>> out;
out["C"] = std::vector<double>(params["A"], 1.0);
// Convert back to a dictionary and return
output[0] = out;
}
Called with:
mex test_mex; test_mex(dictionary(["A", "B"], {100, 1020})); mex, dictionary MATLAB Answers — New Questions
How to have smithPlot with outer area with white colour?
Hi
I was using this code for years giving me perfectly fine smith plots with white colour )inner, outer and background).
figure
sm = smithplot(gca);
hold on
% Set the background color of the outer area to white
ax = gca;
set(gcf, ‘Color’, ‘white’);
% Rest of your code
sm.ArcTickLabelVisible = 0;
sm.CircleTickLabelVisible = 0;
sm.Marker = {‘+’};
sm.GridBackgroundColor = ‘w’;
sm.TitleTopFontSizeMultiplier = 1.75;
sm.GridLineWidth = 1;
I recently upgraded to MATLAB R2024a, and same code gives me smith plot with grau outer area, although I command for a white one.
Any recommnedation on this ?
ThanksHi
I was using this code for years giving me perfectly fine smith plots with white colour )inner, outer and background).
figure
sm = smithplot(gca);
hold on
% Set the background color of the outer area to white
ax = gca;
set(gcf, ‘Color’, ‘white’);
% Rest of your code
sm.ArcTickLabelVisible = 0;
sm.CircleTickLabelVisible = 0;
sm.Marker = {‘+’};
sm.GridBackgroundColor = ‘w’;
sm.TitleTopFontSizeMultiplier = 1.75;
sm.GridLineWidth = 1;
I recently upgraded to MATLAB R2024a, and same code gives me smith plot with grau outer area, although I command for a white one.
Any recommnedation on this ?
Thanks Hi
I was using this code for years giving me perfectly fine smith plots with white colour )inner, outer and background).
figure
sm = smithplot(gca);
hold on
% Set the background color of the outer area to white
ax = gca;
set(gcf, ‘Color’, ‘white’);
% Rest of your code
sm.ArcTickLabelVisible = 0;
sm.CircleTickLabelVisible = 0;
sm.Marker = {‘+’};
sm.GridBackgroundColor = ‘w’;
sm.TitleTopFontSizeMultiplier = 1.75;
sm.GridLineWidth = 1;
I recently upgraded to MATLAB R2024a, and same code gives me smith plot with grau outer area, although I command for a white one.
Any recommnedation on this ?
Thanks smithplot, figure, rf MATLAB Answers — New Questions
Why is the smoothing effect of【 pcolor() shading interp 】worse on 2025a than the old version 2023b
When I updated the latest 2025a, I tried to draw a picture with pcolor() and found that pixel blocks appeared on the picture drawn by the 2025a version, but not in the 2023b version, so I was a little confused why?
The code is as follows,and the data package and operation results are shown in the attachment
clc;clear;close all
load(‘test.mat’)
figure;
figWidth = 14;
figHeight = figWidth * (10 – (-5)) / (160 – 130);
set(gcf, ‘Units’, ‘centimeters’, ‘Position’, [10 10 figWidth figHeight]);
set(gcf, ‘Color’, ‘white’, ‘InvertHardcopy’, ‘off’);
h = pcolor(a, b, d);
shading interp
set(h, ‘EdgeColor’, ‘none’)
caxis([-1.2 1.2])
set(gca, ‘YDir’, ‘reverse’,’TickDir’,’out’, ‘FontSize’, 8, ‘Box’, ‘on’,’FontName’,’Arial’)
colorbar(‘Location’, ‘eastoutside’,’FontName’,’Arial’,’FontWeight’,’normal’);
exportgraphics(gca,’test.pdf’,’BackgroundColor’,’none’,’ContentType’,’vector’,’Resolution’,600)
close allWhen I updated the latest 2025a, I tried to draw a picture with pcolor() and found that pixel blocks appeared on the picture drawn by the 2025a version, but not in the 2023b version, so I was a little confused why?
The code is as follows,and the data package and operation results are shown in the attachment
clc;clear;close all
load(‘test.mat’)
figure;
figWidth = 14;
figHeight = figWidth * (10 – (-5)) / (160 – 130);
set(gcf, ‘Units’, ‘centimeters’, ‘Position’, [10 10 figWidth figHeight]);
set(gcf, ‘Color’, ‘white’, ‘InvertHardcopy’, ‘off’);
h = pcolor(a, b, d);
shading interp
set(h, ‘EdgeColor’, ‘none’)
caxis([-1.2 1.2])
set(gca, ‘YDir’, ‘reverse’,’TickDir’,’out’, ‘FontSize’, 8, ‘Box’, ‘on’,’FontName’,’Arial’)
colorbar(‘Location’, ‘eastoutside’,’FontName’,’Arial’,’FontWeight’,’normal’);
exportgraphics(gca,’test.pdf’,’BackgroundColor’,’none’,’ContentType’,’vector’,’Resolution’,600)
close all When I updated the latest 2025a, I tried to draw a picture with pcolor() and found that pixel blocks appeared on the picture drawn by the 2025a version, but not in the 2023b version, so I was a little confused why?
The code is as follows,and the data package and operation results are shown in the attachment
clc;clear;close all
load(‘test.mat’)
figure;
figWidth = 14;
figHeight = figWidth * (10 – (-5)) / (160 – 130);
set(gcf, ‘Units’, ‘centimeters’, ‘Position’, [10 10 figWidth figHeight]);
set(gcf, ‘Color’, ‘white’, ‘InvertHardcopy’, ‘off’);
h = pcolor(a, b, d);
shading interp
set(h, ‘EdgeColor’, ‘none’)
caxis([-1.2 1.2])
set(gca, ‘YDir’, ‘reverse’,’TickDir’,’out’, ‘FontSize’, 8, ‘Box’, ‘on’,’FontName’,’Arial’)
colorbar(‘Location’, ‘eastoutside’,’FontName’,’Arial’,’FontWeight’,’normal’);
exportgraphics(gca,’test.pdf’,’BackgroundColor’,’none’,’ContentType’,’vector’,’Resolution’,600)
close all pcolor, resolution MATLAB Answers — New Questions