Category: Matlab
Category Archives: Matlab
Polyspace Code Prover incremental/delta analysis
Hi,
is there an option to run Polyspace Code Prover only for changes since the last baseline/commit (basically for files that only changed since the last baseline/commit) ?
This would be crucial to decrease analysis time.
The only adjusting screws for analysis time I know are precision level (-O0, -O1 etc.), verification level (pass0, pass1 etc.) and CPU core count (max-processes option).
We set up PSCP for now locally but the goal is to run it in the CI pipeline and shorter pipeline runs are of course preferred.Hi,
is there an option to run Polyspace Code Prover only for changes since the last baseline/commit (basically for files that only changed since the last baseline/commit) ?
This would be crucial to decrease analysis time.
The only adjusting screws for analysis time I know are precision level (-O0, -O1 etc.), verification level (pass0, pass1 etc.) and CPU core count (max-processes option).
We set up PSCP for now locally but the goal is to run it in the CI pipeline and shorter pipeline runs are of course preferred. Hi,
is there an option to run Polyspace Code Prover only for changes since the last baseline/commit (basically for files that only changed since the last baseline/commit) ?
This would be crucial to decrease analysis time.
The only adjusting screws for analysis time I know are precision level (-O0, -O1 etc.), verification level (pass0, pass1 etc.) and CPU core count (max-processes option).
We set up PSCP for now locally but the goal is to run it in the CI pipeline and shorter pipeline runs are of course preferred. polyspace, polyspace code prover, incremental MATLAB Answers — New Questions
Why do I receive the error “Something went wrong preparing your license for use.”?
1) When accessing MATLAB Online after signing in through my Campus portal page, I receive a message stating "Something went wrong preparing your license for use." If I try to access MATLAB Online directly through matlab.mathworks.com, the message I receive is, "Your MathWorks account is not linked to an active license."
2) When starting a 30 day trial for MATLAB, I receive an error message stating "Something went wrong preparing your license for use".1) When accessing MATLAB Online after signing in through my Campus portal page, I receive a message stating "Something went wrong preparing your license for use." If I try to access MATLAB Online directly through matlab.mathworks.com, the message I receive is, "Your MathWorks account is not linked to an active license."
2) When starting a 30 day trial for MATLAB, I receive an error message stating "Something went wrong preparing your license for use". 1) When accessing MATLAB Online after signing in through my Campus portal page, I receive a message stating "Something went wrong preparing your license for use." If I try to access MATLAB Online directly through matlab.mathworks.com, the message I receive is, "Your MathWorks account is not linked to an active license."
2) When starting a 30 day trial for MATLAB, I receive an error message stating "Something went wrong preparing your license for use". MATLAB Answers — New Questions
Why does an error message appear when clicking a requirement link created using “Link to Selected Requirement” in Test Manager?
I see an error message when I click a requirement link created using "Link to Selected Requirement" in Test Manager.
Error "File not found: ./requirement/z.slreqx (channel: "Test/OpenReqLink")"I see an error message when I click a requirement link created using "Link to Selected Requirement" in Test Manager.
Error "File not found: ./requirement/z.slreqx (channel: "Test/OpenReqLink")" I see an error message when I click a requirement link created using "Link to Selected Requirement" in Test Manager.
Error "File not found: ./requirement/z.slreqx (channel: "Test/OpenReqLink")" to, "test, manager", "how, use" MATLAB Answers — New Questions
Tenable Vulnerability CVS-2026-34480
Is MATLAB R2024a vulnerable to CVE-2026-34480, and is there a security advisory or patch available? The Tenable scanner in our air gapped environment flags this finding as a High vulnerability, so we need to either patch or have something from the vendor we can present to our cybersecurity team. At this time, we cannot upgrade our Matlab version so if there is no patch, we will need to POAM. Thanks!Is MATLAB R2024a vulnerable to CVE-2026-34480, and is there a security advisory or patch available? The Tenable scanner in our air gapped environment flags this finding as a High vulnerability, so we need to either patch or have something from the vendor we can present to our cybersecurity team. At this time, we cannot upgrade our Matlab version so if there is no patch, we will need to POAM. Thanks! Is MATLAB R2024a vulnerable to CVE-2026-34480, and is there a security advisory or patch available? The Tenable scanner in our air gapped environment flags this finding as a High vulnerability, so we need to either patch or have something from the vendor we can present to our cybersecurity team. At this time, we cannot upgrade our Matlab version so if there is no patch, we will need to POAM. Thanks! cvs-2026-34480 MATLAB Answers — New Questions
What’s the Best Way to Convert a .mat File from -v4 format to -v7 Format?
Is there a better way than reading all of the data from the -v4 .mat file and then saving all of the data to a -v7?
data = load(‘v4matfile.mat’);
save("v7matfile.mat","-struct","data","-v7");Is there a better way than reading all of the data from the -v4 .mat file and then saving all of the data to a -v7?
data = load(‘v4matfile.mat’);
save("v7matfile.mat","-struct","data","-v7"); Is there a better way than reading all of the data from the -v4 .mat file and then saving all of the data to a -v7?
data = load(‘v4matfile.mat’);
save("v7matfile.mat","-struct","data","-v7"); save, -v4, -v7 MATLAB Answers — New Questions
List all memoized function caches
I know that clearAllMemoizedCaches will clear all memoized function data, but what if I just want to list all existing memoized caches (and maybe also their cache stats). Is there a way to do that?I know that clearAllMemoizedCaches will clear all memoized function data, but what if I just want to list all existing memoized caches (and maybe also their cache stats). Is there a way to do that? I know that clearAllMemoizedCaches will clear all memoized function data, but what if I just want to list all existing memoized caches (and maybe also their cache stats). Is there a way to do that? memoize MATLAB Answers — New Questions
Make memoized function calls independent of Name/Value argument ordering
In the demo below, we see that the memoized function func() executes twice out of the three times it is called. Ideally, it would only execute upon the first call, but the memoization engine fails to recognize that (1) and (2) are equivalent calls. Is there any way to get a memoized function to ignore differences in the ordering of Name/Value arguments?
mf=memoize(@func);
mf(‘A’,1,’B’,2) %(1) Cached
mf(‘B’,2,’A’,1) %(2) Cached
mf(‘A’,1,’B’,2) %(3) Not Cached
function func(opts)
arguments
opts.A
opts.B
end
disp("Executing")
endIn the demo below, we see that the memoized function func() executes twice out of the three times it is called. Ideally, it would only execute upon the first call, but the memoization engine fails to recognize that (1) and (2) are equivalent calls. Is there any way to get a memoized function to ignore differences in the ordering of Name/Value arguments?
mf=memoize(@func);
mf(‘A’,1,’B’,2) %(1) Cached
mf(‘B’,2,’A’,1) %(2) Cached
mf(‘A’,1,’B’,2) %(3) Not Cached
function func(opts)
arguments
opts.A
opts.B
end
disp("Executing")
end In the demo below, we see that the memoized function func() executes twice out of the three times it is called. Ideally, it would only execute upon the first call, but the memoization engine fails to recognize that (1) and (2) are equivalent calls. Is there any way to get a memoized function to ignore differences in the ordering of Name/Value arguments?
mf=memoize(@func);
mf(‘A’,1,’B’,2) %(1) Cached
mf(‘B’,2,’A’,1) %(2) Cached
mf(‘A’,1,’B’,2) %(3) Not Cached
function func(opts)
arguments
opts.A
opts.B
end
disp("Executing")
end memoize, name/value MATLAB Answers — New Questions
3 dimension array?
Hi,
How to write 3 or 4 dimansion array?
Thanks,
HenryHi,
How to write 3 or 4 dimansion array?
Thanks,
Henry Hi,
How to write 3 or 4 dimansion array?
Thanks,
Henry MATLAB Answers — New Questions
Likely error when doing high dimensional permute of big gpu array
The following code reproduces what appears to be an error when using permute, specifically I permute a matrix contains all positive integers, but the permute output contains zeros.
To trigger the error seems to require three things:
(i) big, say >4gb, array (does not trigger on 3.5gb array)
(ii) gpu array (does not trigger for cpu array)
(iii) high dimensional permute (triggers with 6D, but not 2D)
Following is code to reproduce the issue, and below that a copy-paste of what is printed to command window.
[I use Matlab R2025b, my gpu is detailed in the output.]
%% permutetest.m
% There is an error when permuting BIG GPU arrays with HIGH dimensions.
%
% 1. Doing a permute on a 6D gpu array that is big (roughly >4gb) GIVES ERRORS, specifically this is the ‘Case 1’ below.
% The error is that many elements get replaced with zeros.
%
% 2. Doing the same, but on a smaller (<4gb) gpu array does not error (Case 2 below)
% 3. Redoing first two cases, but on the cpu does not error (Cases 3 and 4)
% 4. Redoing first two cases, but only having permute across 2D does not error (Cases 5 and 6).
%
% The matices being permuted contain integers between 1 and 100, so seems
% unlikely that the actual contents are relevant to the error but I have
% not attempted to test this.
clear all
disp(gpuDevice) % show GPU model + available memory
% Sizes via [4, X, 15, 5, 3, 100]: elements = 90000*X, bytes(double) = 720000*X.
Xmid = 5220; % 469,800,000 elems = 3,758,400,000 bytes = 3.500 GiB (~3.5 GB)
Xhigh = 5966; % 536,940,000 elems = 4,295,520,000 bytes = 4.000 GiB (just above 4 GB)
% mode ‘6D’ => permute(A,[1,2,4,5,3,6]) on the array as-is
% mode ‘2D’ => reshape A to a 2-D matrix [4*X, 22500] then permute(A,[2,1])
%%
cases = {
‘~4.0 GB, GPU, 6-D permute’, [4 Xhigh 15 5 3 100], ‘gpu’, ‘6D’; % big, gpu, high dim
‘~3.5 GB, GPU, 6-D permute’, [4 Xmid 15 5 3 100], ‘gpu’, ‘6D’; % small, gpu, high dim
‘~4.0 GB, CPU, 6-D permute’, [4 Xhigh 15 5 3 100], ‘cpu’, ‘6D’; % big, cpu, high dim
‘~3.5 GB, CPU, 6-D permute’, [4 Xmid 15 5 3 100], ‘cpu’, ‘6D’; % small, cpu, high dim
‘~4.0 GB, GPU, 2-D transpose’, [4 Xhigh 15 5 3 100], ‘gpu’, ‘2D’; % big, gpu, low dim
‘~3.5 GB, GPU, 2-D transpose’, [4 Xmid 15 5 3 100], ‘gpu’, ‘2D’; % small, gpu, low dim
};
%% Do each case and give feedback on results
for ii=1:size(cases,1)
label = cases{ii,1}; sz = cases{ii,2}; dev = cases{ii,3}; mode = cases{ii,4};
% Decide the actual array shape and the permutation order for this case
if strcmp(mode,’2D’)
asize = [sz(1)*sz(2), prod(sz(3:end))]; % e.g. [4*X, 22500]
perm = [2,1];
else
asize = sz;
perm = [1,2,4,5,3,6];
end
nel = prod(asize); nbytes = nel*8; % double = 8 bytes/element
fprintf(‘n===== %s | array=[%s] | perm=[%s] =====n’, label, num2str(asize), num2str(perm));
fprintf(‘ %d elements | %d bytes | %.4f GiB | device=%sn’, nel, nbytes, nbytes/2^30, dev);
%% Pre-permute
% Build with every element >= 1 (so any 0 in the output == corruption), on the chosen device
if strcmp(dev,’gpu’)
A = randi([1 100], asize, ‘gpuArray’); % double, on GPU
else
A = randi([1 100], asize); % double, on CPU
end
sumA = gather(sum(A(:))); % computed BEFORE any permute -> trustworthy
nzA = sum(A(:)==0);
% Double-check the count of zeros pre-permute [passes every time]
if nnz(A)~=(numel(A)-nzA)
error(‘Zero count seems wrong’)
end
fprintf(‘ input : min=%g #zeros=%d sum(A)=%.0fn’, gather(min(A(:))), gather(nzA), sumA);
%% Permute
B = permute(A, perm);
nnz1=nnz(B);
Bc = gather(B); % bring to host for trustworthy checks (no-op if already on CPU)
nnz2=nnz(Bc);
% Double-check that gather() is innocent [it is innocent, this never triggers]
if nnz1~=nnz2
error(‘gather() is not innocent’)
end
%% Post-permute
nzBc = sum(Bc(:)==0);
minB = min(Bc(:));
sumB = sum(Bc(:));
% Double-check the count of zeros post-permute [passes every time]
if nnz(Bc)~=(numel(Bc)-nzBc)
error(‘Zero count seems wrong’)
end
fprintf(‘ output: size=[%s] min=%g #zeros=%d sum(B)=%.0fn’, num2str(size(Bc)), minB, nzBc, sumB);
fprintf(‘ sum preserved? %d (lost %.1f%% of total)n’, sumA==sumB, 100*(sumA-sumB)/sumA);
if nzBc>0 || sumA~=sumB
fprintf(‘ >>> PERMUTE CORRUPTED THIS ARRAY (a faithful permute is impossible here) <<<n’);
else
fprintf(‘ OK: permute faithful (no zeros introduced, sum preserved).n’);
end
% Clean everything up between runs, to make sure nothing corrupts across runs
clear B Bc
clear A
reset(gpuDevice);% free GPU memory before the next allocation
end
fprintf(‘nDone.n’);
When this is run, the following is output to Command Window
>>permutetest
CUDADevice with properties:
Name: ‘NVIDIA RTX 4000 Ada Generation’
Index: 1 (of 1)
ComputeCapability: ‘8.9’
DriverModel: ‘N/A’
TotalMemory: 20991901696 (20.99 GB)
AvailableMemory: 20807024640 (20.81 GB)
DeviceAvailable: true
DeviceSelected: true
Show all properties.
===== ~4.0 GB, GPU, 6-D permute | array=[4 5966 15 5 3 100] | perm=[1 2 4 5 3 6] =====
536940000 elements | 4295520000 bytes | 4.0005 GiB | device=gpu
input : min=1 #zeros=0 sum(A)=27115243076
output: size=[4 5966 5 3 15 100] min=0 #zeros=500387064 sum(B)=1845835241
sum preserved? 0 (lost 93.2% of total)
>>> PERMUTE CORRUPTED THIS ARRAY (a faithful permute is impossible here) <<<
===== ~3.5 GB, GPU, 6-D permute | array=[4 5220 15 5 3 100] | perm=[1 2 4 5 3 6] =====
469800000 elements | 3758400000 bytes | 3.5003 GiB | device=gpu
input : min=1 #zeros=0 sum(A)=23724420469
output: size=[4 5220 5 3 15 100] min=1 #zeros=0 sum(B)=23724420469
sum preserved? 1 (lost 0.0% of total)
OK: permute faithful (no zeros introduced, sum preserved).
===== ~4.0 GB, CPU, 6-D permute | array=[4 5966 15 5 3 100] | perm=[1 2 4 5 3 6] =====
536940000 elements | 4295520000 bytes | 4.0005 GiB | device=cpu
input : min=1 #zeros=0 sum(A)=27115350572
output: size=[4 5966 5 3 15 100] min=1 #zeros=0 sum(B)=27115350572
sum preserved? 1 (lost 0.0% of total)
OK: permute faithful (no zeros introduced, sum preserved).
===== ~3.5 GB, CPU, 6-D permute | array=[4 5220 15 5 3 100] | perm=[1 2 4 5 3 6] =====
469800000 elements | 3758400000 bytes | 3.5003 GiB | device=cpu
input : min=1 #zeros=0 sum(A)=23724663007
output: size=[4 5220 5 3 15 100] min=1 #zeros=0 sum(B)=23724663007
sum preserved? 1 (lost 0.0% of total)
OK: permute faithful (no zeros introduced, sum preserved).
===== ~4.0 GB, GPU, 2-D transpose | array=[23864 22500] | perm=[2 1] =====
536940000 elements | 4295520000 bytes | 4.0005 GiB | device=gpu
input : min=1 #zeros=0 sum(A)=27115442092
output: size=[22500 23864] min=1 #zeros=0 sum(B)=27115442092
sum preserved? 1 (lost 0.0% of total)
OK: permute faithful (no zeros introduced, sum preserved).
===== ~3.5 GB, GPU, 2-D transpose | array=[20880 22500] | perm=[2 1] =====
469800000 elements | 3758400000 bytes | 3.5003 GiB | device=gpu
input : min=1 #zeros=0 sum(A)=23724054242
output: size=[22500 20880] min=1 #zeros=0 sum(B)=23724054242
sum preserved? 1 (lost 0.0% of total)
OK: permute faithful (no zeros introduced, sum preserved).
Done.
>>The following code reproduces what appears to be an error when using permute, specifically I permute a matrix contains all positive integers, but the permute output contains zeros.
To trigger the error seems to require three things:
(i) big, say >4gb, array (does not trigger on 3.5gb array)
(ii) gpu array (does not trigger for cpu array)
(iii) high dimensional permute (triggers with 6D, but not 2D)
Following is code to reproduce the issue, and below that a copy-paste of what is printed to command window.
[I use Matlab R2025b, my gpu is detailed in the output.]
%% permutetest.m
% There is an error when permuting BIG GPU arrays with HIGH dimensions.
%
% 1. Doing a permute on a 6D gpu array that is big (roughly >4gb) GIVES ERRORS, specifically this is the ‘Case 1’ below.
% The error is that many elements get replaced with zeros.
%
% 2. Doing the same, but on a smaller (<4gb) gpu array does not error (Case 2 below)
% 3. Redoing first two cases, but on the cpu does not error (Cases 3 and 4)
% 4. Redoing first two cases, but only having permute across 2D does not error (Cases 5 and 6).
%
% The matices being permuted contain integers between 1 and 100, so seems
% unlikely that the actual contents are relevant to the error but I have
% not attempted to test this.
clear all
disp(gpuDevice) % show GPU model + available memory
% Sizes via [4, X, 15, 5, 3, 100]: elements = 90000*X, bytes(double) = 720000*X.
Xmid = 5220; % 469,800,000 elems = 3,758,400,000 bytes = 3.500 GiB (~3.5 GB)
Xhigh = 5966; % 536,940,000 elems = 4,295,520,000 bytes = 4.000 GiB (just above 4 GB)
% mode ‘6D’ => permute(A,[1,2,4,5,3,6]) on the array as-is
% mode ‘2D’ => reshape A to a 2-D matrix [4*X, 22500] then permute(A,[2,1])
%%
cases = {
‘~4.0 GB, GPU, 6-D permute’, [4 Xhigh 15 5 3 100], ‘gpu’, ‘6D’; % big, gpu, high dim
‘~3.5 GB, GPU, 6-D permute’, [4 Xmid 15 5 3 100], ‘gpu’, ‘6D’; % small, gpu, high dim
‘~4.0 GB, CPU, 6-D permute’, [4 Xhigh 15 5 3 100], ‘cpu’, ‘6D’; % big, cpu, high dim
‘~3.5 GB, CPU, 6-D permute’, [4 Xmid 15 5 3 100], ‘cpu’, ‘6D’; % small, cpu, high dim
‘~4.0 GB, GPU, 2-D transpose’, [4 Xhigh 15 5 3 100], ‘gpu’, ‘2D’; % big, gpu, low dim
‘~3.5 GB, GPU, 2-D transpose’, [4 Xmid 15 5 3 100], ‘gpu’, ‘2D’; % small, gpu, low dim
};
%% Do each case and give feedback on results
for ii=1:size(cases,1)
label = cases{ii,1}; sz = cases{ii,2}; dev = cases{ii,3}; mode = cases{ii,4};
% Decide the actual array shape and the permutation order for this case
if strcmp(mode,’2D’)
asize = [sz(1)*sz(2), prod(sz(3:end))]; % e.g. [4*X, 22500]
perm = [2,1];
else
asize = sz;
perm = [1,2,4,5,3,6];
end
nel = prod(asize); nbytes = nel*8; % double = 8 bytes/element
fprintf(‘n===== %s | array=[%s] | perm=[%s] =====n’, label, num2str(asize), num2str(perm));
fprintf(‘ %d elements | %d bytes | %.4f GiB | device=%sn’, nel, nbytes, nbytes/2^30, dev);
%% Pre-permute
% Build with every element >= 1 (so any 0 in the output == corruption), on the chosen device
if strcmp(dev,’gpu’)
A = randi([1 100], asize, ‘gpuArray’); % double, on GPU
else
A = randi([1 100], asize); % double, on CPU
end
sumA = gather(sum(A(:))); % computed BEFORE any permute -> trustworthy
nzA = sum(A(:)==0);
% Double-check the count of zeros pre-permute [passes every time]
if nnz(A)~=(numel(A)-nzA)
error(‘Zero count seems wrong’)
end
fprintf(‘ input : min=%g #zeros=%d sum(A)=%.0fn’, gather(min(A(:))), gather(nzA), sumA);
%% Permute
B = permute(A, perm);
nnz1=nnz(B);
Bc = gather(B); % bring to host for trustworthy checks (no-op if already on CPU)
nnz2=nnz(Bc);
% Double-check that gather() is innocent [it is innocent, this never triggers]
if nnz1~=nnz2
error(‘gather() is not innocent’)
end
%% Post-permute
nzBc = sum(Bc(:)==0);
minB = min(Bc(:));
sumB = sum(Bc(:));
% Double-check the count of zeros post-permute [passes every time]
if nnz(Bc)~=(numel(Bc)-nzBc)
error(‘Zero count seems wrong’)
end
fprintf(‘ output: size=[%s] min=%g #zeros=%d sum(B)=%.0fn’, num2str(size(Bc)), minB, nzBc, sumB);
fprintf(‘ sum preserved? %d (lost %.1f%% of total)n’, sumA==sumB, 100*(sumA-sumB)/sumA);
if nzBc>0 || sumA~=sumB
fprintf(‘ >>> PERMUTE CORRUPTED THIS ARRAY (a faithful permute is impossible here) <<<n’);
else
fprintf(‘ OK: permute faithful (no zeros introduced, sum preserved).n’);
end
% Clean everything up between runs, to make sure nothing corrupts across runs
clear B Bc
clear A
reset(gpuDevice);% free GPU memory before the next allocation
end
fprintf(‘nDone.n’);
When this is run, the following is output to Command Window
>>permutetest
CUDADevice with properties:
Name: ‘NVIDIA RTX 4000 Ada Generation’
Index: 1 (of 1)
ComputeCapability: ‘8.9’
DriverModel: ‘N/A’
TotalMemory: 20991901696 (20.99 GB)
AvailableMemory: 20807024640 (20.81 GB)
DeviceAvailable: true
DeviceSelected: true
Show all properties.
===== ~4.0 GB, GPU, 6-D permute | array=[4 5966 15 5 3 100] | perm=[1 2 4 5 3 6] =====
536940000 elements | 4295520000 bytes | 4.0005 GiB | device=gpu
input : min=1 #zeros=0 sum(A)=27115243076
output: size=[4 5966 5 3 15 100] min=0 #zeros=500387064 sum(B)=1845835241
sum preserved? 0 (lost 93.2% of total)
>>> PERMUTE CORRUPTED THIS ARRAY (a faithful permute is impossible here) <<<
===== ~3.5 GB, GPU, 6-D permute | array=[4 5220 15 5 3 100] | perm=[1 2 4 5 3 6] =====
469800000 elements | 3758400000 bytes | 3.5003 GiB | device=gpu
input : min=1 #zeros=0 sum(A)=23724420469
output: size=[4 5220 5 3 15 100] min=1 #zeros=0 sum(B)=23724420469
sum preserved? 1 (lost 0.0% of total)
OK: permute faithful (no zeros introduced, sum preserved).
===== ~4.0 GB, CPU, 6-D permute | array=[4 5966 15 5 3 100] | perm=[1 2 4 5 3 6] =====
536940000 elements | 4295520000 bytes | 4.0005 GiB | device=cpu
input : min=1 #zeros=0 sum(A)=27115350572
output: size=[4 5966 5 3 15 100] min=1 #zeros=0 sum(B)=27115350572
sum preserved? 1 (lost 0.0% of total)
OK: permute faithful (no zeros introduced, sum preserved).
===== ~3.5 GB, CPU, 6-D permute | array=[4 5220 15 5 3 100] | perm=[1 2 4 5 3 6] =====
469800000 elements | 3758400000 bytes | 3.5003 GiB | device=cpu
input : min=1 #zeros=0 sum(A)=23724663007
output: size=[4 5220 5 3 15 100] min=1 #zeros=0 sum(B)=23724663007
sum preserved? 1 (lost 0.0% of total)
OK: permute faithful (no zeros introduced, sum preserved).
===== ~4.0 GB, GPU, 2-D transpose | array=[23864 22500] | perm=[2 1] =====
536940000 elements | 4295520000 bytes | 4.0005 GiB | device=gpu
input : min=1 #zeros=0 sum(A)=27115442092
output: size=[22500 23864] min=1 #zeros=0 sum(B)=27115442092
sum preserved? 1 (lost 0.0% of total)
OK: permute faithful (no zeros introduced, sum preserved).
===== ~3.5 GB, GPU, 2-D transpose | array=[20880 22500] | perm=[2 1] =====
469800000 elements | 3758400000 bytes | 3.5003 GiB | device=gpu
input : min=1 #zeros=0 sum(A)=23724054242
output: size=[22500 20880] min=1 #zeros=0 sum(B)=23724054242
sum preserved? 1 (lost 0.0% of total)
OK: permute faithful (no zeros introduced, sum preserved).
Done.
>> The following code reproduces what appears to be an error when using permute, specifically I permute a matrix contains all positive integers, but the permute output contains zeros.
To trigger the error seems to require three things:
(i) big, say >4gb, array (does not trigger on 3.5gb array)
(ii) gpu array (does not trigger for cpu array)
(iii) high dimensional permute (triggers with 6D, but not 2D)
Following is code to reproduce the issue, and below that a copy-paste of what is printed to command window.
[I use Matlab R2025b, my gpu is detailed in the output.]
%% permutetest.m
% There is an error when permuting BIG GPU arrays with HIGH dimensions.
%
% 1. Doing a permute on a 6D gpu array that is big (roughly >4gb) GIVES ERRORS, specifically this is the ‘Case 1’ below.
% The error is that many elements get replaced with zeros.
%
% 2. Doing the same, but on a smaller (<4gb) gpu array does not error (Case 2 below)
% 3. Redoing first two cases, but on the cpu does not error (Cases 3 and 4)
% 4. Redoing first two cases, but only having permute across 2D does not error (Cases 5 and 6).
%
% The matices being permuted contain integers between 1 and 100, so seems
% unlikely that the actual contents are relevant to the error but I have
% not attempted to test this.
clear all
disp(gpuDevice) % show GPU model + available memory
% Sizes via [4, X, 15, 5, 3, 100]: elements = 90000*X, bytes(double) = 720000*X.
Xmid = 5220; % 469,800,000 elems = 3,758,400,000 bytes = 3.500 GiB (~3.5 GB)
Xhigh = 5966; % 536,940,000 elems = 4,295,520,000 bytes = 4.000 GiB (just above 4 GB)
% mode ‘6D’ => permute(A,[1,2,4,5,3,6]) on the array as-is
% mode ‘2D’ => reshape A to a 2-D matrix [4*X, 22500] then permute(A,[2,1])
%%
cases = {
‘~4.0 GB, GPU, 6-D permute’, [4 Xhigh 15 5 3 100], ‘gpu’, ‘6D’; % big, gpu, high dim
‘~3.5 GB, GPU, 6-D permute’, [4 Xmid 15 5 3 100], ‘gpu’, ‘6D’; % small, gpu, high dim
‘~4.0 GB, CPU, 6-D permute’, [4 Xhigh 15 5 3 100], ‘cpu’, ‘6D’; % big, cpu, high dim
‘~3.5 GB, CPU, 6-D permute’, [4 Xmid 15 5 3 100], ‘cpu’, ‘6D’; % small, cpu, high dim
‘~4.0 GB, GPU, 2-D transpose’, [4 Xhigh 15 5 3 100], ‘gpu’, ‘2D’; % big, gpu, low dim
‘~3.5 GB, GPU, 2-D transpose’, [4 Xmid 15 5 3 100], ‘gpu’, ‘2D’; % small, gpu, low dim
};
%% Do each case and give feedback on results
for ii=1:size(cases,1)
label = cases{ii,1}; sz = cases{ii,2}; dev = cases{ii,3}; mode = cases{ii,4};
% Decide the actual array shape and the permutation order for this case
if strcmp(mode,’2D’)
asize = [sz(1)*sz(2), prod(sz(3:end))]; % e.g. [4*X, 22500]
perm = [2,1];
else
asize = sz;
perm = [1,2,4,5,3,6];
end
nel = prod(asize); nbytes = nel*8; % double = 8 bytes/element
fprintf(‘n===== %s | array=[%s] | perm=[%s] =====n’, label, num2str(asize), num2str(perm));
fprintf(‘ %d elements | %d bytes | %.4f GiB | device=%sn’, nel, nbytes, nbytes/2^30, dev);
%% Pre-permute
% Build with every element >= 1 (so any 0 in the output == corruption), on the chosen device
if strcmp(dev,’gpu’)
A = randi([1 100], asize, ‘gpuArray’); % double, on GPU
else
A = randi([1 100], asize); % double, on CPU
end
sumA = gather(sum(A(:))); % computed BEFORE any permute -> trustworthy
nzA = sum(A(:)==0);
% Double-check the count of zeros pre-permute [passes every time]
if nnz(A)~=(numel(A)-nzA)
error(‘Zero count seems wrong’)
end
fprintf(‘ input : min=%g #zeros=%d sum(A)=%.0fn’, gather(min(A(:))), gather(nzA), sumA);
%% Permute
B = permute(A, perm);
nnz1=nnz(B);
Bc = gather(B); % bring to host for trustworthy checks (no-op if already on CPU)
nnz2=nnz(Bc);
% Double-check that gather() is innocent [it is innocent, this never triggers]
if nnz1~=nnz2
error(‘gather() is not innocent’)
end
%% Post-permute
nzBc = sum(Bc(:)==0);
minB = min(Bc(:));
sumB = sum(Bc(:));
% Double-check the count of zeros post-permute [passes every time]
if nnz(Bc)~=(numel(Bc)-nzBc)
error(‘Zero count seems wrong’)
end
fprintf(‘ output: size=[%s] min=%g #zeros=%d sum(B)=%.0fn’, num2str(size(Bc)), minB, nzBc, sumB);
fprintf(‘ sum preserved? %d (lost %.1f%% of total)n’, sumA==sumB, 100*(sumA-sumB)/sumA);
if nzBc>0 || sumA~=sumB
fprintf(‘ >>> PERMUTE CORRUPTED THIS ARRAY (a faithful permute is impossible here) <<<n’);
else
fprintf(‘ OK: permute faithful (no zeros introduced, sum preserved).n’);
end
% Clean everything up between runs, to make sure nothing corrupts across runs
clear B Bc
clear A
reset(gpuDevice);% free GPU memory before the next allocation
end
fprintf(‘nDone.n’);
When this is run, the following is output to Command Window
>>permutetest
CUDADevice with properties:
Name: ‘NVIDIA RTX 4000 Ada Generation’
Index: 1 (of 1)
ComputeCapability: ‘8.9’
DriverModel: ‘N/A’
TotalMemory: 20991901696 (20.99 GB)
AvailableMemory: 20807024640 (20.81 GB)
DeviceAvailable: true
DeviceSelected: true
Show all properties.
===== ~4.0 GB, GPU, 6-D permute | array=[4 5966 15 5 3 100] | perm=[1 2 4 5 3 6] =====
536940000 elements | 4295520000 bytes | 4.0005 GiB | device=gpu
input : min=1 #zeros=0 sum(A)=27115243076
output: size=[4 5966 5 3 15 100] min=0 #zeros=500387064 sum(B)=1845835241
sum preserved? 0 (lost 93.2% of total)
>>> PERMUTE CORRUPTED THIS ARRAY (a faithful permute is impossible here) <<<
===== ~3.5 GB, GPU, 6-D permute | array=[4 5220 15 5 3 100] | perm=[1 2 4 5 3 6] =====
469800000 elements | 3758400000 bytes | 3.5003 GiB | device=gpu
input : min=1 #zeros=0 sum(A)=23724420469
output: size=[4 5220 5 3 15 100] min=1 #zeros=0 sum(B)=23724420469
sum preserved? 1 (lost 0.0% of total)
OK: permute faithful (no zeros introduced, sum preserved).
===== ~4.0 GB, CPU, 6-D permute | array=[4 5966 15 5 3 100] | perm=[1 2 4 5 3 6] =====
536940000 elements | 4295520000 bytes | 4.0005 GiB | device=cpu
input : min=1 #zeros=0 sum(A)=27115350572
output: size=[4 5966 5 3 15 100] min=1 #zeros=0 sum(B)=27115350572
sum preserved? 1 (lost 0.0% of total)
OK: permute faithful (no zeros introduced, sum preserved).
===== ~3.5 GB, CPU, 6-D permute | array=[4 5220 15 5 3 100] | perm=[1 2 4 5 3 6] =====
469800000 elements | 3758400000 bytes | 3.5003 GiB | device=cpu
input : min=1 #zeros=0 sum(A)=23724663007
output: size=[4 5220 5 3 15 100] min=1 #zeros=0 sum(B)=23724663007
sum preserved? 1 (lost 0.0% of total)
OK: permute faithful (no zeros introduced, sum preserved).
===== ~4.0 GB, GPU, 2-D transpose | array=[23864 22500] | perm=[2 1] =====
536940000 elements | 4295520000 bytes | 4.0005 GiB | device=gpu
input : min=1 #zeros=0 sum(A)=27115442092
output: size=[22500 23864] min=1 #zeros=0 sum(B)=27115442092
sum preserved? 1 (lost 0.0% of total)
OK: permute faithful (no zeros introduced, sum preserved).
===== ~3.5 GB, GPU, 2-D transpose | array=[20880 22500] | perm=[2 1] =====
469800000 elements | 3758400000 bytes | 3.5003 GiB | device=gpu
input : min=1 #zeros=0 sum(A)=23724054242
output: size=[22500 20880] min=1 #zeros=0 sum(B)=23724054242
sum preserved? 1 (lost 0.0% of total)
OK: permute faithful (no zeros introduced, sum preserved).
Done.
>> gpu, permute MATLAB Answers — New Questions
reading text and reformatting for excel
Another member of my team has created a modelling programme which outputs data that looks like this:
Train MWh consumed MWh regen V_av. Umean_tr Min V @ km Max V Max Delay(s) @ station
01_02_01 0.2498 -0.0209 1.5755 1.474 1.1937 0.027523 1.8
01_02_02 0.2496 -0.0259 1.5717 1.4722 1.1937 0.027523 1.7963
01_02_03 0.2496 -0.0277 1.569 1.4723 1.1937 0.027523 1.7963
01_02_04 0.2494 -0.0299 1.5628 1.4614 1.1938 0.027523 1.798
01_02_05 0.2497 -0.0299 1.5628 1.4621 1.1941 0.027523 1.7974
01_02_06 0.2497 -0.0299 1.5628 1.4621 1.1941 0.027523 1.7974
01_02_07 0.2497 -0.0299 1.5628 1.4621 1.1941 0.027523 1.7974
01_02_08 0.2497 -0.0299 1.5628 1.4621 1.1941 0.027523 1.7974
01_02_09 0.2497 -0.0299 1.5628 1.4621 1.1941 0.027523 1.7974
01_02_10 0.2497 -0.0299 1.5628 1.4621 1.1941 0.027523 1.7974
01_02_11 0.2497 -0.0296 1.5629 1.4621 1.1941 0.027523 1.7985
01_02_12 0.2497 -0.0272 1.5691 1.4646 1.1941 0.027523 1.8
I want to read the ‘table’ and reformat it into excel. Is that likely to be simple or should I delve into the depths of his programme and print them to the excel sheet directly?Another member of my team has created a modelling programme which outputs data that looks like this:
Train MWh consumed MWh regen V_av. Umean_tr Min V @ km Max V Max Delay(s) @ station
01_02_01 0.2498 -0.0209 1.5755 1.474 1.1937 0.027523 1.8
01_02_02 0.2496 -0.0259 1.5717 1.4722 1.1937 0.027523 1.7963
01_02_03 0.2496 -0.0277 1.569 1.4723 1.1937 0.027523 1.7963
01_02_04 0.2494 -0.0299 1.5628 1.4614 1.1938 0.027523 1.798
01_02_05 0.2497 -0.0299 1.5628 1.4621 1.1941 0.027523 1.7974
01_02_06 0.2497 -0.0299 1.5628 1.4621 1.1941 0.027523 1.7974
01_02_07 0.2497 -0.0299 1.5628 1.4621 1.1941 0.027523 1.7974
01_02_08 0.2497 -0.0299 1.5628 1.4621 1.1941 0.027523 1.7974
01_02_09 0.2497 -0.0299 1.5628 1.4621 1.1941 0.027523 1.7974
01_02_10 0.2497 -0.0299 1.5628 1.4621 1.1941 0.027523 1.7974
01_02_11 0.2497 -0.0296 1.5629 1.4621 1.1941 0.027523 1.7985
01_02_12 0.2497 -0.0272 1.5691 1.4646 1.1941 0.027523 1.8
I want to read the ‘table’ and reformat it into excel. Is that likely to be simple or should I delve into the depths of his programme and print them to the excel sheet directly? Another member of my team has created a modelling programme which outputs data that looks like this:
Train MWh consumed MWh regen V_av. Umean_tr Min V @ km Max V Max Delay(s) @ station
01_02_01 0.2498 -0.0209 1.5755 1.474 1.1937 0.027523 1.8
01_02_02 0.2496 -0.0259 1.5717 1.4722 1.1937 0.027523 1.7963
01_02_03 0.2496 -0.0277 1.569 1.4723 1.1937 0.027523 1.7963
01_02_04 0.2494 -0.0299 1.5628 1.4614 1.1938 0.027523 1.798
01_02_05 0.2497 -0.0299 1.5628 1.4621 1.1941 0.027523 1.7974
01_02_06 0.2497 -0.0299 1.5628 1.4621 1.1941 0.027523 1.7974
01_02_07 0.2497 -0.0299 1.5628 1.4621 1.1941 0.027523 1.7974
01_02_08 0.2497 -0.0299 1.5628 1.4621 1.1941 0.027523 1.7974
01_02_09 0.2497 -0.0299 1.5628 1.4621 1.1941 0.027523 1.7974
01_02_10 0.2497 -0.0299 1.5628 1.4621 1.1941 0.027523 1.7974
01_02_11 0.2497 -0.0296 1.5629 1.4621 1.1941 0.027523 1.7985
01_02_12 0.2497 -0.0272 1.5691 1.4646 1.1941 0.027523 1.8
I want to read the ‘table’ and reformat it into excel. Is that likely to be simple or should I delve into the depths of his programme and print them to the excel sheet directly? text file, excel, export, output, matrix, strings MATLAB Answers — New Questions
Getting wrong output when Modelling a VFD powered by a generator, feeding a motor
Hello Everyone, I am trying to model an VFD which is powered by an AC Generator, feeding an induction motor. I got a model online, where the guy takes a pure DC supply as the source. I modified his model, replacing it with AC Supply and a rectifier. The model works well with DC supply, however it gives wrong output when a AC Generator with a rectifier is connected.
Below is the model powered by a DC source, this works perfectly.
Below is the model with AC source, this gives wierd outputs.
This is the voltage produced by rectifier
This is the Voltage Produced by invertor
Below is the motor torque and rpm
I would really appreciate if someone can help me figure out what is wrong in my system, Thanks.Hello Everyone, I am trying to model an VFD which is powered by an AC Generator, feeding an induction motor. I got a model online, where the guy takes a pure DC supply as the source. I modified his model, replacing it with AC Supply and a rectifier. The model works well with DC supply, however it gives wrong output when a AC Generator with a rectifier is connected.
Below is the model powered by a DC source, this works perfectly.
Below is the model with AC source, this gives wierd outputs.
This is the voltage produced by rectifier
This is the Voltage Produced by invertor
Below is the motor torque and rpm
I would really appreciate if someone can help me figure out what is wrong in my system, Thanks. Hello Everyone, I am trying to model an VFD which is powered by an AC Generator, feeding an induction motor. I got a model online, where the guy takes a pure DC supply as the source. I modified his model, replacing it with AC Supply and a rectifier. The model works well with DC supply, however it gives wrong output when a AC Generator with a rectifier is connected.
Below is the model powered by a DC source, this works perfectly.
Below is the model with AC source, this gives wierd outputs.
This is the voltage produced by rectifier
This is the Voltage Produced by invertor
Below is the motor torque and rpm
I would really appreciate if someone can help me figure out what is wrong in my system, Thanks. motor, generator, specialized power systems, sps MATLAB Answers — New Questions
How do I increase the fontsize used to display text in the Copilot Chat window of the Matlab IDE?
How do I increase the fontsize used to display text in the Copilot Chat window of the Matlab IDE?How do I increase the fontsize used to display text in the Copilot Chat window of the Matlab IDE? How do I increase the fontsize used to display text in the Copilot Chat window of the Matlab IDE? copilot chat MATLAB Answers — New Questions
Accessing a single GPU from different workers of a parpool thread pool
It used to be conventional wisdom that parfor does not play well together with gpuArray on a single-GPU system because different parpool workers end up competing for the same CPU-GPU communication channel. Is that still true now that there is a distinction between process pools and thread pools? Can it be worthwhile to parfor-parallelize a loop containing gpuArray operations if I have only a single GPU?It used to be conventional wisdom that parfor does not play well together with gpuArray on a single-GPU system because different parpool workers end up competing for the same CPU-GPU communication channel. Is that still true now that there is a distinction between process pools and thread pools? Can it be worthwhile to parfor-parallelize a loop containing gpuArray operations if I have only a single GPU? It used to be conventional wisdom that parfor does not play well together with gpuArray on a single-GPU system because different parpool workers end up competing for the same CPU-GPU communication channel. Is that still true now that there is a distinction between process pools and thread pools? Can it be worthwhile to parfor-parallelize a loop containing gpuArray operations if I have only a single GPU? gpu, parpool, thread pools, process pools MATLAB Answers — New Questions
Initialization in Simulink
Is it possible to run a Simulink model with model variables initialized directly from a stored file accessed by Simulink instead of being them being initialized within MATLAB? Whenever I run a Simulink model it seems that I first have to assign values to any MATLAB workspace variables by going into MATLAB- it would be easier if they could be automatically initialized within Simulink. Is that possible?Is it possible to run a Simulink model with model variables initialized directly from a stored file accessed by Simulink instead of being them being initialized within MATLAB? Whenever I run a Simulink model it seems that I first have to assign values to any MATLAB workspace variables by going into MATLAB- it would be easier if they could be automatically initialized within Simulink. Is that possible? Is it possible to run a Simulink model with model variables initialized directly from a stored file accessed by Simulink instead of being them being initialized within MATLAB? Whenever I run a Simulink model it seems that I first have to assign values to any MATLAB workspace variables by going into MATLAB- it would be easier if they could be automatically initialized within Simulink. Is that possible? eric1, callback MATLAB Answers — New Questions
Overwriting table columns with ()-indexing
Suppose I have two tables,
T1=array2table(rand(5,3))
T2=array2table(char(randi([65,90],5,3)),Var={‘Col1′,’Col2′,’Col3’})
I wish to replace the final column of T1 with that of T2. One way to accomplish this is,
T3=[T1(:,1:2) , T2(:,3) ]
Why, though, does this indexing approach not give the same result?
T3=T1;
T3(:,3)=T2(:,3)
The result is the same as what would be obtained with brace indexing,
T3=T1;
T3{:,3}=T2{:,3}
I understand why brace-indexing gives this result, but I thought ()-indexing was supposed to keep the data contained in a table. Why don’t the tabular properties of T2(:,3), like the column name and data type, get transfered as well when parentheses are used?Suppose I have two tables,
T1=array2table(rand(5,3))
T2=array2table(char(randi([65,90],5,3)),Var={‘Col1′,’Col2′,’Col3’})
I wish to replace the final column of T1 with that of T2. One way to accomplish this is,
T3=[T1(:,1:2) , T2(:,3) ]
Why, though, does this indexing approach not give the same result?
T3=T1;
T3(:,3)=T2(:,3)
The result is the same as what would be obtained with brace indexing,
T3=T1;
T3{:,3}=T2{:,3}
I understand why brace-indexing gives this result, but I thought ()-indexing was supposed to keep the data contained in a table. Why don’t the tabular properties of T2(:,3), like the column name and data type, get transfered as well when parentheses are used? Suppose I have two tables,
T1=array2table(rand(5,3))
T2=array2table(char(randi([65,90],5,3)),Var={‘Col1′,’Col2′,’Col3’})
I wish to replace the final column of T1 with that of T2. One way to accomplish this is,
T3=[T1(:,1:2) , T2(:,3) ]
Why, though, does this indexing approach not give the same result?
T3=T1;
T3(:,3)=T2(:,3)
The result is the same as what would be obtained with brace indexing,
T3=T1;
T3{:,3}=T2{:,3}
I understand why brace-indexing gives this result, but I thought ()-indexing was supposed to keep the data contained in a table. Why don’t the tabular properties of T2(:,3), like the column name and data type, get transfered as well when parentheses are used? table, indexing MATLAB Answers — New Questions
Wrong frequency and waveform distortion when reading 50Hz AC voltage using F29H85x ADC triggered by ePWM in Simulink
I have this ADC processing structure for the F29H85x in MATLAB to measure a 50Hz AC voltage. The ADC is triggered by an ePWM at a frequency of 10kHz, and the resulting sine wave is captured on the scope as shown. Please help me analyze the issue and give me solution. ThanksI have this ADC processing structure for the F29H85x in MATLAB to measure a 50Hz AC voltage. The ADC is triggered by an ePWM at a frequency of 10kHz, and the resulting sine wave is captured on the scope as shown. Please help me analyze the issue and give me solution. Thanks I have this ADC processing structure for the F29H85x in MATLAB to measure a 50Hz AC voltage. The ADC is triggered by an ePWM at a frequency of 10kHz, and the resulting sine wave is captured on the scope as shown. Please help me analyze the issue and give me solution. Thanks adc f29h85x MATLAB Answers — New Questions
Why can’t I use “end-2:end” for the meaning of last 2 columns?
Post Content Post Content tutorial MATLAB Answers — New Questions
datetime sometimes returns NaT and sometimes throws an error – what is the expected behaviour?
Sometimes datetime throws an error if it can’t return a valid datetime object from a string input:
dt = datetime(["2026_06" "2026_06_13"], Format = "yyyy_MM_dd")
and sometimes it returns NaT:
dt = datetime(["2026_06_13" "2026_06"], Format = "yyyy_MM_dd")
dt =
1×2 datetime array
2026_06_13 NaT
The second result is what I’d expect from the documentation. I’m having difficulty figuring out what the underlying rule is, since the two examples have the same input apart from the order and the same format. It seems to be to do with whether the first element of the array can be interpreted according to the format.
It looks like I have to put every call to datetime in a try-catch block and also test the result result for NaT, if I’m to detect any non-conforming input. This seems excessive – can anyone suggest a better way, or whether this is actually a bug I should try to report?Sometimes datetime throws an error if it can’t return a valid datetime object from a string input:
dt = datetime(["2026_06" "2026_06_13"], Format = "yyyy_MM_dd")
and sometimes it returns NaT:
dt = datetime(["2026_06_13" "2026_06"], Format = "yyyy_MM_dd")
dt =
1×2 datetime array
2026_06_13 NaT
The second result is what I’d expect from the documentation. I’m having difficulty figuring out what the underlying rule is, since the two examples have the same input apart from the order and the same format. It seems to be to do with whether the first element of the array can be interpreted according to the format.
It looks like I have to put every call to datetime in a try-catch block and also test the result result for NaT, if I’m to detect any non-conforming input. This seems excessive – can anyone suggest a better way, or whether this is actually a bug I should try to report? Sometimes datetime throws an error if it can’t return a valid datetime object from a string input:
dt = datetime(["2026_06" "2026_06_13"], Format = "yyyy_MM_dd")
and sometimes it returns NaT:
dt = datetime(["2026_06_13" "2026_06"], Format = "yyyy_MM_dd")
dt =
1×2 datetime array
2026_06_13 NaT
The second result is what I’d expect from the documentation. I’m having difficulty figuring out what the underlying rule is, since the two examples have the same input apart from the order and the same format. It seems to be to do with whether the first element of the array can be interpreted according to the format.
It looks like I have to put every call to datetime in a try-catch block and also test the result result for NaT, if I’m to detect any non-conforming input. This seems excessive – can anyone suggest a better way, or whether this is actually a bug I should try to report? datetime, datetime nat, datetime error MATLAB Answers — New Questions
solve system of 6
% Define symbolic variables
syms g alpha1 alpha2 sigma c b s1 s2 beta2 E1 U
% Use 0.5 instead of 0.1e1 ./ 0.2e1 for clarity
g_plus_half = g + 0.5;
g_minus_half = g – 0.5;
row1 = [2, 2, 2*besselk(g_plus_half, alpha1), 2*besselk(g_plus_half, alpha2), 2*besseli(g_plus_half, alpha1), 2*besseli(g_plus_half, alpha2)];
row2 = [-7, 2, …
(-3*alpha1*besselk(g_minus_half, alpha1) – besselk(g_plus_half, alpha1)*sigma – 7*besselk(g_plus_half, alpha1)), …
(-3*alpha2*besselk(g_minus_half, alpha2) – besselk(g_plus_half, alpha2)*sigma – 7*besselk(g_plus_half, alpha2)), …
(3*alpha1*besseli(g_minus_half, alpha1) – besseli(g_plus_half, alpha1)*sigma – 7*besseli(g_plus_half, alpha1)), …
(3*alpha2*besseli(g_minus_half, alpha2) – besseli(g_plus_half, alpha2)*sigma – 7*besseli(g_plus_half, alpha2))];
% Simplified row3
term1 = (alpha1^2 * c + alpha1^2 – sigma) / (2*c);
term2 = (alpha2^2 * c + alpha2^2 – sigma) / (2*c);
row3 = [0, 0, …
term1 * (besselk(g_plus_half, alpha1)*beta2*s1*s2 + alpha1*beta2*s1*besselk(g_minus_half, alpha1) + 2*besselk(g_plus_half, alpha1)*beta2*s1 + besselk(g_plus_half, alpha1)), …
term2 * (besselk(g_plus_half, alpha2)*beta2*s1*s2 + alpha2*beta2*s1*besselk(g_minus_half, alpha2) + 2*besselk(g_plus_half, alpha2)*beta2*s1 + besselk(g_plus_half, alpha2)), …
term1 * (besseli(g_plus_half, alpha1)*beta2*s1*s2 – alpha1*beta2*s1*besseli(g_minus_half, alpha1) + 2*besseli(g_plus_half, alpha1)*beta2*s1 + besseli(g_plus_half, alpha1)), …
term2 * (besseli(g_plus_half, alpha2)*beta2*s1*s2 – alpha2*beta2*s1*besseli(g_minus_half, alpha2) + 2*besseli(g_plus_half, alpha2)*beta2*s1 + besseli(g_plus_half, alpha2))];
row4 = [2/(b^3), 2, 2*besselk(g_plus_half, b*alpha1)*b^(-1.5), 2*besselk(g_plus_half, b*alpha2)*b^(-1.5), 2*besseli(g_plus_half, b*alpha1)*b^(-1.5), 2*besseli(g_plus_half, b*alpha2)*b^(-1.5)];
row5 = [-1/(b^3), 2, …
-(alpha1*besselk(g_minus_half, b*alpha1)*b + besselk(g_plus_half, b*alpha1))*b^(-1.5), …
-(alpha2*besselk(g_minus_half, b*alpha2)*b + besselk(g_plus_half, b*alpha2))*b^(-1.5), …
-(-besseli(g_minus_half, b*alpha1)*alpha1*b + besseli(g_plus_half, b*alpha1))*b^(-1.5), …
-(-besseli(g_minus_half, b*alpha2)*alpha2*b + besseli(g_plus_half, b*alpha2))*b^(-1.5)];
row6 = [0, 0, …
(alpha1^2*b^2*c + alpha1^2*b^2 – b^2*sigma) * besselk(g_plus_half, b*alpha1) / (2*c) * b^(-2.5), …
(alpha2^2*b^2*c + alpha2^2*b^2 – b^2*sigma) * besselk(g_plus_half, b*alpha2) / (2*c) * b^(-2.5), …
(alpha1^2*b^2*c + alpha1^2*b^2 – b^2*sigma) * besseli(g_plus_half, b*alpha1) / (2*c) * b^(-2.5), …
(alpha2^2*b^2*c + alpha2^2*b^2 – b^2*sigma) * besseli(g_plus_half, b*alpha2) / (2*c) * b^(-2.5)];
% Assemble matrix
A = [row1; row2; row3; row4; row5; row6];
% Rename ‘b’ to ‘rhs’ to avoid conflict
rhs = [-U; U; 0; 0; 0; 0];
% Solve symbolically
sol = linsolve(A, rhs);% Define symbolic variables
syms g alpha1 alpha2 sigma c b s1 s2 beta2 E1 U
% Use 0.5 instead of 0.1e1 ./ 0.2e1 for clarity
g_plus_half = g + 0.5;
g_minus_half = g – 0.5;
row1 = [2, 2, 2*besselk(g_plus_half, alpha1), 2*besselk(g_plus_half, alpha2), 2*besseli(g_plus_half, alpha1), 2*besseli(g_plus_half, alpha2)];
row2 = [-7, 2, …
(-3*alpha1*besselk(g_minus_half, alpha1) – besselk(g_plus_half, alpha1)*sigma – 7*besselk(g_plus_half, alpha1)), …
(-3*alpha2*besselk(g_minus_half, alpha2) – besselk(g_plus_half, alpha2)*sigma – 7*besselk(g_plus_half, alpha2)), …
(3*alpha1*besseli(g_minus_half, alpha1) – besseli(g_plus_half, alpha1)*sigma – 7*besseli(g_plus_half, alpha1)), …
(3*alpha2*besseli(g_minus_half, alpha2) – besseli(g_plus_half, alpha2)*sigma – 7*besseli(g_plus_half, alpha2))];
% Simplified row3
term1 = (alpha1^2 * c + alpha1^2 – sigma) / (2*c);
term2 = (alpha2^2 * c + alpha2^2 – sigma) / (2*c);
row3 = [0, 0, …
term1 * (besselk(g_plus_half, alpha1)*beta2*s1*s2 + alpha1*beta2*s1*besselk(g_minus_half, alpha1) + 2*besselk(g_plus_half, alpha1)*beta2*s1 + besselk(g_plus_half, alpha1)), …
term2 * (besselk(g_plus_half, alpha2)*beta2*s1*s2 + alpha2*beta2*s1*besselk(g_minus_half, alpha2) + 2*besselk(g_plus_half, alpha2)*beta2*s1 + besselk(g_plus_half, alpha2)), …
term1 * (besseli(g_plus_half, alpha1)*beta2*s1*s2 – alpha1*beta2*s1*besseli(g_minus_half, alpha1) + 2*besseli(g_plus_half, alpha1)*beta2*s1 + besseli(g_plus_half, alpha1)), …
term2 * (besseli(g_plus_half, alpha2)*beta2*s1*s2 – alpha2*beta2*s1*besseli(g_minus_half, alpha2) + 2*besseli(g_plus_half, alpha2)*beta2*s1 + besseli(g_plus_half, alpha2))];
row4 = [2/(b^3), 2, 2*besselk(g_plus_half, b*alpha1)*b^(-1.5), 2*besselk(g_plus_half, b*alpha2)*b^(-1.5), 2*besseli(g_plus_half, b*alpha1)*b^(-1.5), 2*besseli(g_plus_half, b*alpha2)*b^(-1.5)];
row5 = [-1/(b^3), 2, …
-(alpha1*besselk(g_minus_half, b*alpha1)*b + besselk(g_plus_half, b*alpha1))*b^(-1.5), …
-(alpha2*besselk(g_minus_half, b*alpha2)*b + besselk(g_plus_half, b*alpha2))*b^(-1.5), …
-(-besseli(g_minus_half, b*alpha1)*alpha1*b + besseli(g_plus_half, b*alpha1))*b^(-1.5), …
-(-besseli(g_minus_half, b*alpha2)*alpha2*b + besseli(g_plus_half, b*alpha2))*b^(-1.5)];
row6 = [0, 0, …
(alpha1^2*b^2*c + alpha1^2*b^2 – b^2*sigma) * besselk(g_plus_half, b*alpha1) / (2*c) * b^(-2.5), …
(alpha2^2*b^2*c + alpha2^2*b^2 – b^2*sigma) * besselk(g_plus_half, b*alpha2) / (2*c) * b^(-2.5), …
(alpha1^2*b^2*c + alpha1^2*b^2 – b^2*sigma) * besseli(g_plus_half, b*alpha1) / (2*c) * b^(-2.5), …
(alpha2^2*b^2*c + alpha2^2*b^2 – b^2*sigma) * besseli(g_plus_half, b*alpha2) / (2*c) * b^(-2.5)];
% Assemble matrix
A = [row1; row2; row3; row4; row5; row6];
% Rename ‘b’ to ‘rhs’ to avoid conflict
rhs = [-U; U; 0; 0; 0; 0];
% Solve symbolically
sol = linsolve(A, rhs); % Define symbolic variables
syms g alpha1 alpha2 sigma c b s1 s2 beta2 E1 U
% Use 0.5 instead of 0.1e1 ./ 0.2e1 for clarity
g_plus_half = g + 0.5;
g_minus_half = g – 0.5;
row1 = [2, 2, 2*besselk(g_plus_half, alpha1), 2*besselk(g_plus_half, alpha2), 2*besseli(g_plus_half, alpha1), 2*besseli(g_plus_half, alpha2)];
row2 = [-7, 2, …
(-3*alpha1*besselk(g_minus_half, alpha1) – besselk(g_plus_half, alpha1)*sigma – 7*besselk(g_plus_half, alpha1)), …
(-3*alpha2*besselk(g_minus_half, alpha2) – besselk(g_plus_half, alpha2)*sigma – 7*besselk(g_plus_half, alpha2)), …
(3*alpha1*besseli(g_minus_half, alpha1) – besseli(g_plus_half, alpha1)*sigma – 7*besseli(g_plus_half, alpha1)), …
(3*alpha2*besseli(g_minus_half, alpha2) – besseli(g_plus_half, alpha2)*sigma – 7*besseli(g_plus_half, alpha2))];
% Simplified row3
term1 = (alpha1^2 * c + alpha1^2 – sigma) / (2*c);
term2 = (alpha2^2 * c + alpha2^2 – sigma) / (2*c);
row3 = [0, 0, …
term1 * (besselk(g_plus_half, alpha1)*beta2*s1*s2 + alpha1*beta2*s1*besselk(g_minus_half, alpha1) + 2*besselk(g_plus_half, alpha1)*beta2*s1 + besselk(g_plus_half, alpha1)), …
term2 * (besselk(g_plus_half, alpha2)*beta2*s1*s2 + alpha2*beta2*s1*besselk(g_minus_half, alpha2) + 2*besselk(g_plus_half, alpha2)*beta2*s1 + besselk(g_plus_half, alpha2)), …
term1 * (besseli(g_plus_half, alpha1)*beta2*s1*s2 – alpha1*beta2*s1*besseli(g_minus_half, alpha1) + 2*besseli(g_plus_half, alpha1)*beta2*s1 + besseli(g_plus_half, alpha1)), …
term2 * (besseli(g_plus_half, alpha2)*beta2*s1*s2 – alpha2*beta2*s1*besseli(g_minus_half, alpha2) + 2*besseli(g_plus_half, alpha2)*beta2*s1 + besseli(g_plus_half, alpha2))];
row4 = [2/(b^3), 2, 2*besselk(g_plus_half, b*alpha1)*b^(-1.5), 2*besselk(g_plus_half, b*alpha2)*b^(-1.5), 2*besseli(g_plus_half, b*alpha1)*b^(-1.5), 2*besseli(g_plus_half, b*alpha2)*b^(-1.5)];
row5 = [-1/(b^3), 2, …
-(alpha1*besselk(g_minus_half, b*alpha1)*b + besselk(g_plus_half, b*alpha1))*b^(-1.5), …
-(alpha2*besselk(g_minus_half, b*alpha2)*b + besselk(g_plus_half, b*alpha2))*b^(-1.5), …
-(-besseli(g_minus_half, b*alpha1)*alpha1*b + besseli(g_plus_half, b*alpha1))*b^(-1.5), …
-(-besseli(g_minus_half, b*alpha2)*alpha2*b + besseli(g_plus_half, b*alpha2))*b^(-1.5)];
row6 = [0, 0, …
(alpha1^2*b^2*c + alpha1^2*b^2 – b^2*sigma) * besselk(g_plus_half, b*alpha1) / (2*c) * b^(-2.5), …
(alpha2^2*b^2*c + alpha2^2*b^2 – b^2*sigma) * besselk(g_plus_half, b*alpha2) / (2*c) * b^(-2.5), …
(alpha1^2*b^2*c + alpha1^2*b^2 – b^2*sigma) * besseli(g_plus_half, b*alpha1) / (2*c) * b^(-2.5), …
(alpha2^2*b^2*c + alpha2^2*b^2 – b^2*sigma) * besseli(g_plus_half, b*alpha2) / (2*c) * b^(-2.5)];
% Assemble matrix
A = [row1; row2; row3; row4; row5; row6];
% Rename ‘b’ to ‘rhs’ to avoid conflict
rhs = [-U; U; 0; 0; 0; 0];
% Solve symbolically
sol = linsolve(A, rhs); solve system MATLAB Answers — New Questions
creating mesh from geo file in gmsh using matlab?
Hello All,
I am trying to create a mesh file from a geo file that is created by MATLAB.
Can I directly call gmsh and do meshing through some command in MATLAB?
I have seen few examples but not so clear. It will be great if someone can help me to do the meshing.
I have attached my geo file. Its a txt version.
Thanking you in advance,
kmHello All,
I am trying to create a mesh file from a geo file that is created by MATLAB.
Can I directly call gmsh and do meshing through some command in MATLAB?
I have seen few examples but not so clear. It will be great if someone can help me to do the meshing.
I have attached my geo file. Its a txt version.
Thanking you in advance,
km Hello All,
I am trying to create a mesh file from a geo file that is created by MATLAB.
Can I directly call gmsh and do meshing through some command in MATLAB?
I have seen few examples but not so clear. It will be great if someone can help me to do the meshing.
I have attached my geo file. Its a txt version.
Thanking you in advance,
km gmsh, mesh, workspace MATLAB Answers — New Questions









