Category: News
NaN values when attempting Motion Read for a UAV Scenario
I’m currently attempting to get platform or sensor related motion data from my UAV 3d scenario Simulink Model. Attached is the current block diagram:
I have the UAV scenario configuration block, the SImulation 3D scene configuration block, and the UAV Scenario Motion Read block, connected to my workspace as shown above. The UAV scenario block is configured for the singleUAVScenario function, which spawns a single quadrotor. The control part and this configuration were taken from an example in MATLAB’s documentation, so all bus, signal, and data blocks’ names are unchanged. When I run the model, initially the values are updating, as shown:
However, more or less after a single second passes in my simulation, for some reason, my data goes to NaN values for the rest of the simulation, no matter how long it is, as shown here:
Obviously, when I take the data to MATLAB using a To Workspace block, I have the same issue.
I’ve tried running another MATLAB example; quick access for that is this:
openExample(‘uav/SimulateUAVScenarioUsingScenarioBlocksExample’)
In that simulink model, the displays constantly update and there are no nan issues. Can anyone provide any answers? Sorry if it’s an easy fix, I don’t have too much experience in this particular area. Is it the sampling time, some inherent issue? I’m assuming that, according to the matlab documentation for the UAV scenario configuration block…
This block internally stores motion states from platforms and sensors in a global data store memory block as buses within a bus with a name specified in the Scenario motion bus name parameter.
That the motion parameters are automatically stored in this global data store memory block, and by using the read block, I can simply get the motion data. Do let me know if any additional information is needed, I can provide.
Note: Data goes to NaN after an exact second in simulation time has elapsed. No matter what the simulation step size is, the data seems constant except for the Position data for the first second, but instantly after, everything goes to NaN (except platform ID). The constant data also may be wrong, I suspect.I’m currently attempting to get platform or sensor related motion data from my UAV 3d scenario Simulink Model. Attached is the current block diagram:
I have the UAV scenario configuration block, the SImulation 3D scene configuration block, and the UAV Scenario Motion Read block, connected to my workspace as shown above. The UAV scenario block is configured for the singleUAVScenario function, which spawns a single quadrotor. The control part and this configuration were taken from an example in MATLAB’s documentation, so all bus, signal, and data blocks’ names are unchanged. When I run the model, initially the values are updating, as shown:
However, more or less after a single second passes in my simulation, for some reason, my data goes to NaN values for the rest of the simulation, no matter how long it is, as shown here:
Obviously, when I take the data to MATLAB using a To Workspace block, I have the same issue.
I’ve tried running another MATLAB example; quick access for that is this:
openExample(‘uav/SimulateUAVScenarioUsingScenarioBlocksExample’)
In that simulink model, the displays constantly update and there are no nan issues. Can anyone provide any answers? Sorry if it’s an easy fix, I don’t have too much experience in this particular area. Is it the sampling time, some inherent issue? I’m assuming that, according to the matlab documentation for the UAV scenario configuration block…
This block internally stores motion states from platforms and sensors in a global data store memory block as buses within a bus with a name specified in the Scenario motion bus name parameter.
That the motion parameters are automatically stored in this global data store memory block, and by using the read block, I can simply get the motion data. Do let me know if any additional information is needed, I can provide.
Note: Data goes to NaN after an exact second in simulation time has elapsed. No matter what the simulation step size is, the data seems constant except for the Position data for the first second, but instantly after, everything goes to NaN (except platform ID). The constant data also may be wrong, I suspect. I’m currently attempting to get platform or sensor related motion data from my UAV 3d scenario Simulink Model. Attached is the current block diagram:
I have the UAV scenario configuration block, the SImulation 3D scene configuration block, and the UAV Scenario Motion Read block, connected to my workspace as shown above. The UAV scenario block is configured for the singleUAVScenario function, which spawns a single quadrotor. The control part and this configuration were taken from an example in MATLAB’s documentation, so all bus, signal, and data blocks’ names are unchanged. When I run the model, initially the values are updating, as shown:
However, more or less after a single second passes in my simulation, for some reason, my data goes to NaN values for the rest of the simulation, no matter how long it is, as shown here:
Obviously, when I take the data to MATLAB using a To Workspace block, I have the same issue.
I’ve tried running another MATLAB example; quick access for that is this:
openExample(‘uav/SimulateUAVScenarioUsingScenarioBlocksExample’)
In that simulink model, the displays constantly update and there are no nan issues. Can anyone provide any answers? Sorry if it’s an easy fix, I don’t have too much experience in this particular area. Is it the sampling time, some inherent issue? I’m assuming that, according to the matlab documentation for the UAV scenario configuration block…
This block internally stores motion states from platforms and sensors in a global data store memory block as buses within a bus with a name specified in the Scenario motion bus name parameter.
That the motion parameters are automatically stored in this global data store memory block, and by using the read block, I can simply get the motion data. Do let me know if any additional information is needed, I can provide.
Note: Data goes to NaN after an exact second in simulation time has elapsed. No matter what the simulation step size is, the data seems constant except for the Position data for the first second, but instantly after, everything goes to NaN (except platform ID). The constant data also may be wrong, I suspect. uav toolbox, nan values, simulink MATLAB Answers — New Questions
How to import multiple .mat files into the same workspace
Hello,
I have multiple .mat files that contain different arrays.
These arrays have the same name in each .mat file; I need to open two or more .mat files to elaborate the data.
The problem is that the content of the most recent .mat file overwrites the previous one since the name of the arrays is always the same.
For example, let’s say I have test1.mat that contains:
accel
effort
gyro
and test2.mat that contains:
accel
effort
gyro
Is there a way to be able to load into the workspace the arrays coming from test1 and test2 at the same time?Hello,
I have multiple .mat files that contain different arrays.
These arrays have the same name in each .mat file; I need to open two or more .mat files to elaborate the data.
The problem is that the content of the most recent .mat file overwrites the previous one since the name of the arrays is always the same.
For example, let’s say I have test1.mat that contains:
accel
effort
gyro
and test2.mat that contains:
accel
effort
gyro
Is there a way to be able to load into the workspace the arrays coming from test1 and test2 at the same time? Hello,
I have multiple .mat files that contain different arrays.
These arrays have the same name in each .mat file; I need to open two or more .mat files to elaborate the data.
The problem is that the content of the most recent .mat file overwrites the previous one since the name of the arrays is always the same.
For example, let’s say I have test1.mat that contains:
accel
effort
gyro
and test2.mat that contains:
accel
effort
gyro
Is there a way to be able to load into the workspace the arrays coming from test1 and test2 at the same time? matlab, arrays, import MATLAB Answers — New Questions
Temperature determination difference between codes that should do the same thing!
So, I do research of laser heating metals. We have this code (main code) that separates each hotspot into different qudrants to analyze. Occacsionally, one quadrant nees to be excluded from the calculations (2nd code). So the main code, uses the LT (left top) as the focus for analyzing. The 2nd code, needs to do the analysis with LD (Left down) as the focus instead adn exclude everything that has to do with LT.
So the issue is: the tempeartures calculated from the 2nd code are 300 to 400 K too low. (pics of ffure with each code.). If you have any isight I would greatly appreciate it!
Here is the normal code:
clear;close all;
[filename, pathname, filterindex] = uigetfile(‘*.txt’, ‘Enter input data file..’);
fullname = fullfile(pathname, filename);
mydata = importdata(fullname);
hotspot_ob=double(mydata);
scale= 120; % size of the box 90*90
subpixel=4;
hscale=scale/2;
[k,l]=size(hotspot_ob);
SR=ones(size(hotspot_ob));
box_Num = 1; % box 1 or 2
ND_Num = 0; % 0, .5, 1, 2
switch ND_Num
case 0
ND_col = 1;
case .5
ND_col = 2;
case 1
ND_col = 3;
case 2
ND_col = 4;
end
%LATEST from 08/09/2023
box(1).rs = [ 1.0 1.0 1.0 1.0
1.05 1.101 1.14 1.14
0.803 1.12 1.54 4.17
0.645 0.788 0.929 2.82];
box(2).rs = [1.0 1.0 1.0 1
0.296 0.312 0.325 0.424
0.331 0.457 0.632 1.735
0.245 0.294 0.348 1.077];
SR(1:fix(k/2),1:fix(l/2)) = box(box_Num).rs(1,ND_col);
SR(1:fix(k/2),fix(l/2)+1:l) = box(box_Num).rs(2,ND_col);
SR(fix(k/2)+1:k,1:fix(l/2)) = box(box_Num).rs(3,ND_col);
SR(fix(k/2)+1:k,fix(l/2)+1:l) = box(box_Num).rs(4,ND_col);
hotspot=hotspot_ob./SR;
[V_lt,H_lt]=find_max(hotspot_ob,1,fix(k/2),1,fix(l/2));
%V_lt=140;H_lt=166;
[V_rt,H_rt]=find_max(hotspot_ob,1,fix(k/2),fix(l/2)+1,l);
[V_ld,H_ld]=find_max(hotspot_ob,fix(k/2)+1,k,1,fix(l/2));
[V_rd,H_rd]=find_max(hotspot_ob,fix(k/2)+1,k,fix(l/2)+1,l);
%%find max for hotspot for later T correction Jie add on Mar2216, two ways:
%%neigther seem to work properly
%1st find the strongest point and make it as threshold–find corresponding
%intensities in other quadrants
hotspot_lt = hotspot(1:fix(k/2),1:fix(l/2)); [k_lt, l_lt] = size(hotspot_lt);
hotspot_rt = hotspot(1:fix(k/2),(fix(l/2)+1):l); [k_rt, l_rt] = size(hotspot_rt);
hotspot_ld = hotspot((fix(k/2)+1):k,1:fix(l/2)); [k_ld, l_ld] = size(hotspot_ld);
hotspot_rd = hotspot((fix(k/2)+1):k,(fix(l/2)+1):l); [k_rd, l_rd] = size(hotspot_rd);
[m_lt,n_lt]=find_max(hotspot_lt,1,k_lt,1,l_lt);
[m_rt,n_rt]=find_max(hotspot_rt,1,k_rt,1,l_rt);
[m_ld,n_ld]=find_max(hotspot_ld,1,k_ld,1,l_ld);
[m_rd,n_rd]=find_max(hotspot_rd,1,k_rd,1,l_rd);
misfit = zeros(4,1);
misfit(1,1) = (hotspot_rt(m_rt,n_rt)-hotspot_rt(m_lt,n_lt)).^2+(hotspot_ld(m_ld,n_ld)-hotspot_ld(m_lt,n_lt)).^2 …
+(hotspot_rd(m_rd,n_rd)-hotspot_rd(m_lt,n_lt)).^2;
misfit(2,1) = (hotspot_lt(m_rt,n_rt)-hotspot_lt(m_rt,n_rt)).^2+(hotspot_ld(m_rt,n_rt)-hotspot_ld(m_rt,n_rt)).^2 …
+(hotspot_rd(m_rt,n_rt)-hotspot_rd(m_rt,n_rt)).^2;
misfit(3,1) = (hotspot_lt(m_ld,n_ld)-hotspot_lt(m_ld,n_ld)).^2+(hotspot_rt(m_ld,n_ld)-hotspot_rt(m_ld,n_ld)).^2 …
+(hotspot_rd(m_ld,n_ld)-hotspot_rd(m_ld,n_ld)).^2;
misfit(4,1) = (hotspot_lt(m_rd,n_rd)-hotspot_ld(m_rd,n_rd)).^2+(hotspot_rt(m_rd,n_rd)-hotspot_rt(m_rd,n_rd)).^2 …
+(hotspot_ld(m_rd,n_rd)-hotspot_ld(m_rd,n_rd)).^2;
switch min(misfit)
case misfit(1,1)
mm = m_lt; nn = n_lt;
case misfit(2,1)
mm = m_rt; nn = n_rt;
case misfit(3,1)
mm = m_ld; nn = n_ld;
case misfit(4,1)
mm = m_rd; nn = n_rd;
end
Max_color = [hotspot_lt(mm,nn) hotspot_rt(mm,nn) hotspot_ld(mm,nn) hotspot_rd(mm,nn)]
m = min([k_lt;k_rt;k_ld;k_rd]); n = min([l_lt;l_rt;l_ld;l_rd]);
misfit2 = zeros(m,n);
for countm = 1:m
for countn = 1:n
misfit2(countm,countn) = (hotspot_lt(countm,countn)-hotspot_lt(m_lt,n_lt)).^2 + (hotspot_rt(countm,countn)-hotspot_rt(m_rt,n_rt)).^2 …
+(hotspot_ld(countm,countn)-hotspot_ld(m_ld,n_ld)).^2+(hotspot_rd(countm,countn)-hotspot_rd(m_rd,n_rd)).^2;
end
end
for countm = 1:m
for countn = 1:n
if misfit2(countm,countn) == min(min(misfit2))
mmm = countm; nnn = countn;
end
end
end
Max_color2 = [hotspot_lt(mmm,nnn) hotspot_rt(mmm,nnn) hotspot_ld(mmm,nnn) hotspot_rd(mmm,nnn)]
%%
center_LT=[V_lt,H_lt];
center_LD=[V_ld,H_ld];
center_RT=[V_rt,H_rt];
center_RD=[V_rd,H_rd];
% Define the bounds of the matrix
k_max = size(hotspot, 1);
l_max = size(hotspot, 2);
% Ensure the indices are within valid bounds
V_lt_start = max(V_lt-hscale, 1);
V_lt_end = min(V_lt+hscale, k_max);
H_lt_start = max(H_lt-hscale, 1);
H_lt_end = min(H_lt+hscale, l_max);
V_ld_start = max(V_ld-hscale, 1);
V_ld_end = min(V_ld+hscale, k_max);
H_ld_start = max(H_ld-hscale, 1);
H_ld_end = min(H_ld+hscale, l_max);
V_rt_start = max(V_rt-hscale, 1);
V_rt_end = min(V_rt+hscale, k_max);
H_rt_start = max(H_rt-hscale, 1);
H_rt_end = min(H_rt+hscale, l_max);
V_rd_start = max(V_rd-hscale, 1);
V_rd_end = min(V_rd+hscale, k_max);
H_rd_start = max(H_rd-hscale, 1);
H_rd_end = min(H_rd+hscale, l_max);
% Now extract the subarrays with valid indices
LT = hotspot(V_lt_start:V_lt_end, H_lt_start:H_lt_end);
LD = hotspot(V_ld_start:V_ld_end, H_ld_start:H_ld_end);
RT = hotspot(V_rt_start:V_rt_end, H_rt_start:H_rt_end);
RD = hotspot(V_rd_start:V_rd_end, H_rd_start:H_rd_end);
% Find New centers and update them
[center_RT_new,Cor_RT] = imagematching (hotspot,LT,center_RT,scale); % use LT as target image
[center_LD_new,Cor_LD] = imagematching (hotspot,LT,center_LD,scale);
[center_RD_new,Cor_RD] = imagematching (hotspot,LT,center_RD,scale);
center_LD=center_LD_new;
center_RT=center_RT_new;
center_RD=center_RD_new;
[inter_center_RT,Cor_RT] = intermatching (hotspot,LT,center_RT_new,scale,subpixel);
[inter_center_LD,Cor_LD] = intermatching (hotspot,LT,center_LD_new,scale,subpixel);
[inter_center_RD,Cor_RD] = intermatching (hotspot,LT,center_RD_new,scale,subpixel);
center_LD=inter_center_LD;
center_RT=inter_center_RT;
center_RD=inter_center_RD;
Cor=[1 Cor_RT;Cor_LD Cor_RD];
V_ld=center_LD(1,1); H_ld=center_LD(1,2);
V_rt=center_RT(1,1); H_rt=center_RT(1,2);
V_rd=center_RD(1,1); H_rd=center_RD(1,2);
[XI_ld,YI_ld]=meshgrid(H_ld-hscale:H_ld+hscale,V_ld-hscale:V_ld+hscale);
[XI_rt,YI_rt]=meshgrid(H_rt-hscale:H_rt+hscale,V_rt-hscale:V_rt+hscale);
[XI_rd,YI_rd]=meshgrid(H_rd-hscale:H_rd+hscale,V_rd-hscale:V_rd+hscale);
LD=interp2(hotspot,XI_ld,YI_ld); % update images
RT=interp2(hotspot,XI_rt,YI_rt);
RD=interp2(hotspot,XI_rd,YI_rd);
lamda_LT=580*10^(-9);
lamda_RT=640*10^(-9);
lamda_LD=766*10^(-9);
lamda_RD=905*10^(-9);
planck=6.6*10^(-34);
Kb=1.38*10^(-23);
c=3*10^8;
Wien_LT=Kb/planck/c*log(2*pi*planck*c*c./LT/lamda_LT^5);
Wien_RT=Kb/planck/c*log(2*pi*planck*c*c./RT/lamda_RT^5);
Wien_LD=Kb/planck/c*log(2*pi*planck*c*c./LD/lamda_LD^5);
Wien_RD=Kb/planck/c*log(2*pi*planck*c*c./RD/lamda_RD^5);
[m,n]=size(LT);
for i=1:m
for j=1:n
X=[1/lamda_LT 1/lamda_RT 1/lamda_LD 1/lamda_RD]’;
% X=[1/lamda_650 1/lamda_800 1/lamda_900]’;
X_reg=[X ones(size(X))];
Y=[Wien_LT(i,j) Wien_RT(i,j) Wien_LD(i,j) Wien_RD(i,j)]’;
% Y=[Wien_LT(i,j) Wien_LD(i,j) Wien_RD(i,j)]’;
%R(i,j)=corrcoef(X,Y);
[T_inv,bint]=regress(Y,X_reg); %% bint is 95% confidence level of T
R(i,j)=corr(X,Y);
T(i,j)=1/T_inv(1,1); %% T_inv(1,1) is for T
Em(i,j)=exp(-T_inv(2,1)*planck*c/Kb); %% T_inv(2,1) is for emissivity
T_err(i,j)=(1/bint(1,1)-1/bint(1,2))/2; %% difference between upper limit of T – lower limit of T
T_low(i,j)=1/bint(1,2);
T_high(i,j)=1/bint(1,1);
end
end
%% max in four regimes Jie add on Dec 5th 2015
[max_LT,Indexing] = max(LT(:))
max_RD = max(max(RD));max_LD = max(max(LD));max_RT = max(max(RT));
Max_color4 = [LT(Indexing) RT(Indexing) LD(Indexing) RD(Indexing)]
%% max grid search Jie add on April 1st
[m,n]=size(RD);
misfit3 = zeros(m,n);
for countm = 1:m
for countn = 1:n
misfit3(countm,countn) = (LT(countm,countn)-max_LT).^2 + (RT(countm,countn)-max_RT).^2 …
+(LD(countm,countn)-max_LD).^2+(RD(countm,countn)-max_RD).^2;
end
end
for countm = 1:m
for countn = 1:n
if misfit3(countm,countn) == min(min(misfit3))
m4 = countm; n4 = countn;
end
end
end
Max_color3 = [LT(m4,n4) RT(m4,n4) LD(m4,n4) RD(m4,n4)];
Max_Ih = [LT(m4,:); RT(m4,:); LD(m4,:); RD(m4,:)];
Max_Iv = [LT(:,n4)’; RT(:,n4)’; LD(:,n4)’; RD(:,n4)’];
%%
figure(‘Name’,’hotspot’);
imagesc(hotspot_ob);
figure(‘Name’,’hot spot in 4 regions’);
subplot(2,2,1)
imagesc(LT);
subplot(2,2,2)
imagesc(RT);
subplot(2,2,3)
imagesc(LD);
subplot(2,2,4)
imagesc(RD);
figure(‘Name’,’T profile (pixel)’);
imagesc(T);
[Max_T, H]=max(max(T)); % maximum Temperature, horizontal position
[Max_T, V]=max(max(T’)); % maximum Temperature, vertical position
grid=0.48; % each pixel is 0.5um
X_position=(-H+1)*grid: grid: (scale-H+1)*grid;
figure(‘Name’,’Hirizontal T profile throughh highest T point’)
plot (X_position, T(V, :));
title(‘horizotal plot’)
xlabel(‘horizontal positon/um’)
ylabel (‘temperature/K’);
figure(‘Name’,’Vertical T profile throughh highest T point’)
Y_position=(-V+1)*grid: grid: (scale-V+1)*grid;
plot(Y_position,T(:,H));
title(‘Vertical plot’)
xlabel(‘Vertical positon/um’)
ylabel (‘temperature/K’);
[Y_p,X_p]=meshgrid(X_position, Y_position);
figure(‘Name’,’3D T profile’)
surf(X_p,Y_p,T);
xlabel(‘Horizontal distance(um)’)
ylabel (‘Vetical distance(um)’);
zlabel(‘Temperature(K)’)
shading interp;
figure(‘Name’,’T profile (pixel)’);
imagesc(X_position,Y_position,T);
xlabel(‘Horizontal distance(um)’)
ylabel (‘Vetical distance(um)’);
colormap(‘turbo’)
colorbar;
figure(‘Name’,’T profile (pixel) contour’);
imagesc(X_position,Y_position,T);
xlabel(‘Horizontal distance(um)’)
ylabel (‘Vetical distance(um)’);
colormap(‘turbo’)
colorbar;
hold on; % Keep the image displayed while adding contour
contour(X_position, Y_position, T, 10, ‘LineWidth’, 1, ‘LineColor’, ‘w’); % 40 contours, white lines
hold off; % Release the hold on the current figure
figure(‘Name’,’T error’);
imagesc(X_position,Y_position,T_err);
figure(‘Name’,’Emissivity Profile’)
imagesc(X_position,Y_position,log10(Em));
figure(‘Name’,’3D Emissivity profile’)
surf(X_p,Y_p,log10(Em));
H=scale/2; V=scale/2;% give the point needed to plot T cross section
figure(‘Name’,’Vertical Em/Emax vs T trough highest T point’)
plot(T(:,H),Em(:,H)/max(Em(:,H)),’–rs’);
title(‘Vertical plot’)
xlabel(‘Temperature’)
ylabel (‘Em/Em_max’);
figure(‘Name’,’horizontal Em/Emax vs T trough highest T point’)
plot(T(V,:),Em(V,:)/max(Em(V,:)),’–rs’);
title(‘horizontal Em/Emax vs T’)
xlabel(‘Temperature’)
ylabel (‘Em/Em_max’);
% figure(12); % 3D image for intensity in 4 regions
% subplot(2,2,1)
% surf(X_p,Y_p,LT);
% subplot(2,2,2)
% surf(X_p,Y_p,RT);
% subplot(2,2,3)
% surf(X_p,Y_p,LD);
% subplot(2,2,4)
% surf(X_p,Y_p,RD)
figure (‘Name’,’Emissivity vs T over whole space’); plot(T,Em);
Image result:
2nd code:
clear; close all
[filename, pathname, filterindex]=uigetfile(‘*.txt’, ‘Enter input data file..’);
fullname=fullfile(pathname, filename);
mydata=importdata(fullname);
hotspot_ob=double(mydata);
scale=120;
subpixel=4;
hscale=scale/2;
[k,l]=size(hotspot_ob);
SR=ones(size(hotspot_ob));
box_Num = 1; % box 1 or 2
ND_Num = 0; % 0, .5, 1, 2
switch ND_Num
case 0
ND_col = 1;
case .5
ND_col = 2;
case 1
ND_col = 3;
case 2
ND_col = 4;
end
%LATEST from 08/09/2023
box(1).rs = [ 1.0 1.0 1.0 1.0
1.05 1.101 1.14 1.14
0.803 1.12 1.54 4.17
0.645 0.788 0.929 2.82];
box(2).rs = [1.0 1.0 1.0 1
0.296 0.312 0.325 0.424
0.331 0.457 0.632 1.735
0.245 0.294 0.348 1.077];
SR(1:fix(k/2),1:fix(l/2)) = box(box_Num).rs(1,ND_col);
SR(1:fix(k/2),fix(l/2)+1:l) = box(box_Num).rs(2,ND_col);
SR(fix(k/2)+1:k,1:fix(l/2)) = box(box_Num).rs(3,ND_col);
SR(fix(k/2)+1:k,fix(l/2)+1:l) = box(box_Num).rs(4,ND_col);
hotspot=hotspot_ob./SR;
[V_lt,H_lt]=find_max(hotspot_ob,1,fix(k/2),1,fix(l/2));
[V_rt,H_rt]=find_max(hotspot_ob,1,fix(k/2),fix(l/2)+1,l);
[V_ld,H_ld]=find_max(hotspot_ob,fix(k/2)+1,k,1,fix(l/2));
[V_rd,H_rd]=find_max(hotspot_ob,fix(k/2)+1,k,fix(l/2)+1,l);
hotspot_lt = hotspot(1:fix(k/2),1:fix(l/2)); [k_lt, l_lt] = size(hotspot_lt);
hotspot_rt = hotspot(1:fix(k/2),(fix(l/2)+1):l); [k_rt, l_rt] = size(hotspot_rt);
hotspot_ld = hotspot((fix(k/2)+1):k,1:fix(l/2)); [k_ld, l_ld] = size(hotspot_ld);
hotspot_rd = hotspot((fix(k/2)+1):k,(fix(l/2)+1):l); [k_rd, l_rd] = size(hotspot_rd);
%V_lt=98; H_lt=150;
[m_lt,n_lt]=find_max(hotspot_lt,1,k_lt,1,l_lt);
[m_rt,n_rt]=find_max(hotspot_rt,1,k_rt,1,l_rt);
[m_ld,n_ld]=find_max(hotspot_ld,1,k_ld,1,l_ld);
[m_rd,n_rd]=find_max(hotspot_rd,1,k_rd,1,l_rd);
misfit = zeros(4,1);
misfit(1,1) = (hotspot_rt(m_rt,n_rt)-hotspot_rt(m_lt,n_lt)).^2+(hotspot_ld(m_ld,n_ld)-hotspot_ld(m_lt,n_lt)).^2 …
+(hotspot_rd(m_rd,n_rd)-hotspot_rd(m_lt,n_lt)).^2;
misfit(2,1) = (hotspot_lt(m_rt,n_rt)-hotspot_lt(m_rt,n_rt)).^2+(hotspot_ld(m_rt,n_rt)-hotspot_ld(m_rt,n_rt)).^2 …
+(hotspot_rd(m_rt,n_rt)-hotspot_rd(m_rt,n_rt)).^2;
misfit(3,1) = (hotspot_lt(m_ld,n_ld)-hotspot_lt(m_ld,n_ld)).^2+(hotspot_rt(m_ld,n_ld)-hotspot_rt(m_ld,n_ld)).^2 …
+(hotspot_rd(m_ld,n_ld)-hotspot_rd(m_ld,n_ld)).^2;
misfit(4,1) = (hotspot_lt(m_rd,n_rd)-hotspot_ld(m_rd,n_rd)).^2+(hotspot_rt(m_rd,n_rd)-hotspot_rt(m_rd,n_rd)).^2 …
+(hotspot_ld(m_rd,n_rd)-hotspot_ld(m_rd,n_rd)).^2;
switch min(misfit)
case misfit(1,1)
mm = m_lt; nn = n_lt;
case misfit(2,1)
mm = m_rt; nn = n_rt;
case misfit(3,1)
mm = m_ld; nn = n_ld;
case misfit(4,1)
mm = m_rd; nn = n_rd;
end
Max_color = [ hotspot_rt(mm,nn) hotspot_ld(mm,nn) hotspot_rd(mm,nn)]
m = min([k_lt;k_rt;k_ld;k_rd]); n = min([l_lt;l_rt;l_ld;l_rd]);
misfit2 = zeros(m,n);
for countm = 1:m
for countn = 1:n
misfit2(countm,countn) = (hotspot_rt(countm,countn)-hotspot_rt(m_rt,n_rt)).^2 …
+(hotspot_ld(countm,countn)-hotspot_ld(m_ld,n_ld)).^2+(hotspot_rd(countm,countn)-hotspot_rd(m_rd,n_rd)).^2;
end
end
for countm = 1:m
for countn = 1:n
if misfit2(countm,countn) == min(min(misfit2))
mmm = countm; nnn = countn;
end
end
end
Max_color2 = [hotspot_rt(mmm,nnn) hotspot_ld(mmm,nnn) hotspot_rd(mmm,nnn)]
%V_lt=126; H_lt=176;
%V_rt=125; H_rt=565;
%V_ld=398; H_ld=179;
%V_rd=388; H_rd=580;
center_LT=[V_lt,H_lt];
center_LD=[V_ld, H_ld];
center_RT=[V_rt,H_rt];
center_RD=[V_rd,H_rd];
LT=hotspot(V_lt-hscale:V_lt+hscale,H_lt-hscale:H_lt+hscale);
LD=hotspot(V_ld-hscale:V_ld+hscale,H_ld-hscale:H_ld+hscale);
RT=hotspot(V_rt-hscale:V_rt+hscale,H_rt-hscale:H_rt+hscale);
RD=hotspot(V_rd-hscale:V_rd+hscale,H_rd-hscale:H_rd+hscale);
% Find New centers and update them
[center_LT_new,Cor_LT] = imagematching (hotspot,RD,center_RT,scale); % use RT as target image
[center_LD_new,Cor_LD] = imagematching (hotspot,RD,center_LD,scale);
[center_RT_new,Cor_RT] = imagematching (hotspot,RD,center_RD,scale);
center_LD=center_LD_new;
center_LT=center_LT_new;
center_RT=center_RT_new;
[inter_center_LT,Cor_LT] = intermatching (hotspot,RD,center_LT_new,scale,subpixel);
[inter_center_LD,Cor_LD] = intermatching (hotspot,RD,center_LD_new,scale,subpixel);
[inter_center_RT,Cor_RT] = intermatching (hotspot,RD,center_RT_new,scale,subpixel);
center_LD=inter_center_LD;
center_LT=inter_center_LT;
center_RT=inter_center_RT;
Cor=[1 Cor_LT;Cor_LD Cor_RT];
V_ld=center_LD(1,1); H_ld=center_LD(1,2);
V_rt=center_LT(1,1); H_lt=center_LT(1,2);
V_rd=center_RD(1,1); H_rd=center_RD(1,2);
[XI_ld,YI_ld]=meshgrid(H_ld-hscale:H_ld+hscale,V_ld-hscale:V_ld+hscale);
[XI_lt,YI_lt]=meshgrid(H_lt-hscale:H_lt+hscale,V_lt-hscale:V_lt+hscale);
[XI_rd,YI_rd]=meshgrid(H_rd-hscale:H_rd+hscale,V_rd-hscale:V_rd+hscale);
LD=interp2(hotspot,XI_ld,YI_ld,’spline’); % update images
LT=interp2(hotspot,XI_lt,YI_lt,’spline’);
RD=interp2(hotspot,XI_rd,YI_rd,’spline’);
% Assuming you want to exclude 580 nm
lamda_LT=580*10^(-9);
lamda_RT=640*10^(-9);
lamda_LD=766*10^(-9);
lamda_RD=905*10^(-9);
planck=6.6*10^(-34);
Kb=1.38*10^(-23);
c=3*10^8;
%Wien_LT=Kb/planck/c*log(2*pi*planck*c*c./LT/lamda_LT^5);
Wien_RT=Kb/planck/c*log(2*pi*planck*c*c./RT/lamda_RT^5);
Wien_LD=Kb/planck/c*log(2*pi*planck*c*c./LD/lamda_LD^5);
Wien_RD=Kb/planck/c*log(2*pi*planck*c*c./RD/lamda_RD^5);
[m,n]=size(LD);
for i=1:m
for j=1:n
X=[1/lamda_RT 1/lamda_LD 1/lamda_RD]’;
%X=[1/lamda_650 1/lamda_800 1/lamda_900]’;
X_reg=[X ones(size(X))];
%Y=[Wien_LT(i,j) Wien_LD(i,j) Wien_RD(i,j)]’;
Y=[Wien_RT(i,j) Wien_LD(i,j) Wien_RD(i,j)]’;
%R(i,j)=corrcoef(X,Y);
[T_inv,bint]=regress(Y,X_reg);
R(i,j)=corr(X,Y);
T(i,j)=1/T_inv(1,1);
Em(i,j)=exp(-T_inv(2,1)*planck*c/Kb);
T_err(i,j)=(1/bint(1,1)-1/bint(1,2))/2;
T_low(i,j)=1/bint(1,2);
T_high(i,j)=1/bint(1,1);
end
end
%% max in four regimes Jie add on Dec 5th 2015
[max_RD,Indexing] = max(RD(:))
max_LD = max(max(LD));max_RT = max(max(RT));
Max_color4 = [RT(Indexing) LD(Indexing) RD(Indexing)]
%% max grid search Jie add on April 1st
[m,n]=size(RD);
misfit3 = zeros(m,n);
for countm = 1:m
for countn = 1:n
misfit3(countm,countn) = (RT(countm,countn)-max_RT).^2 …
+(LD(countm,countn)-max_LD).^2+(RD(countm,countn)-max_RD).^2;
end
end
for countm = 1:m
for countn = 1:n
if misfit3(countm,countn) == min(min(misfit3))
m4 = countm; n4 = countn;
end
end
end
Max_color3 = [ RT(m4,n4) LD(m4,n4) RD(m4,n4)];
Max_Ih = [ RT(m4,:); LD(m4,:); RD(m4,:)];
Max_Iv = [ RT(:,n4)’; LD(:,n4)’; RD(:,n4)’];
figure(‘Name’,’hotspot’);
imagesc(hotspot_ob);
figure(‘Name’,’hot spot in 4 regions’);
subplot(2,2,2)
imagesc(RT);
subplot(2,2,3)
imagesc(LD);
subplot(2,2,4)
imagesc(RD);
figure(‘Name’,’T profile (pixel)’);
imagesc(T);
[Max_T, H]=max(max(T)); % maximum Temperature, horizontal position
[Max_T, V]=max(max(T’)); % maximum Temperature, vertical position
grid=0.48; % each pixel is 0.5um
X_position=(-H+1)*grid: grid: (scale-H+1)*grid;
figure(‘Name’,’Hirizontal T profile throughh highest T point’)
plot (X_position, T(V, :));
title(‘horizotal plot’)
xlabel(‘horizontal positon/um’)
ylabel (‘temperature/K’);
figure(‘Name’,’Vertical T profile throughh highest T point’)
Y_position=(-V+1)*grid: grid: (scale-V+1)*grid;
plot(Y_position,T(:,H));
title(‘Vertical plot’)
xlabel(‘Vertical positon/um’)
ylabel (‘temperature/K’);
[Y_p,X_p]=meshgrid(X_position, Y_position);
figure(‘Name’,’3D T profile’)
surf(X_p,Y_p,T);
xlabel(‘Horizontal distance(um)’)
ylabel (‘Vetical distance(um)’);
zlabel(‘Temperature(K)’)
shading interp;
figure(‘Name’,’T profile (pixel)’);
imagesc(X_position,Y_position,T);
xlabel(‘Horizontal distance(um)’)
ylabel (‘Vetical distance(um)’);
colormap(‘turbo’)
colorbar;
figure(‘Name’,’T profile (pixel) contour’);
imagesc(X_position,Y_position,T);
xlabel(‘Horizontal distance(um)’)
ylabel (‘Vetical distance(um)’);
colormap(‘turbo’)
colorbar;
hold on; % Keep the image displayed while adding contour
contour(X_position, Y_position, T, 10, ‘LineWidth’, 1, ‘LineColor’, ‘w’); % 40 contours, white lines
hold off; % Release the hold on the current figure
figure(‘Name’,’T error’);
imagesc(X_position,Y_position,T_err);
figure(‘Name’,’Emissivity Profile’)
imagesc(X_position,Y_position,log10(Em));
figure(‘Name’,’3D Emissivity profile’)
surf(X_p,Y_p,log10(Em));
H=scale/2; V=scale/2;% give the point needed to plot T cross section
figure(‘Name’,’Vertical Em/Emax vs T trough highest T point’)
plot(T(:,H),Em(:,H)/max(Em(:,H)),’–rs’);
title(‘Vertical plot’)
xlabel(‘Temperature’)
ylabel (‘Em/Em_max’);
figure(‘Name’,’horizontal Em/Emax vs T trough highest T point’)
plot(T(V,:),Em(V,:)/max(Em(V,:)),’–rs’);
title(‘horizontal Em/Emax vs T’)
xlabel(‘Temperature’)
ylabel (‘Em/Em_max’);
% figure(12); % 3D image for intensity in 4 regions
% subplot(2,2,1)
% surf(X_p,Y_p,LT);
% subplot(2,2,2)
% surf(X_p,Y_p,RT);
% subplot(2,2,3)
% surf(X_p,Y_p,LD);
% subplot(2,2,4)
% surf(X_p,Y_p,RD)
figure (‘Name’,’Emissivity vs T over whole space’); plot(T,Em);
image result:So, I do research of laser heating metals. We have this code (main code) that separates each hotspot into different qudrants to analyze. Occacsionally, one quadrant nees to be excluded from the calculations (2nd code). So the main code, uses the LT (left top) as the focus for analyzing. The 2nd code, needs to do the analysis with LD (Left down) as the focus instead adn exclude everything that has to do with LT.
So the issue is: the tempeartures calculated from the 2nd code are 300 to 400 K too low. (pics of ffure with each code.). If you have any isight I would greatly appreciate it!
Here is the normal code:
clear;close all;
[filename, pathname, filterindex] = uigetfile(‘*.txt’, ‘Enter input data file..’);
fullname = fullfile(pathname, filename);
mydata = importdata(fullname);
hotspot_ob=double(mydata);
scale= 120; % size of the box 90*90
subpixel=4;
hscale=scale/2;
[k,l]=size(hotspot_ob);
SR=ones(size(hotspot_ob));
box_Num = 1; % box 1 or 2
ND_Num = 0; % 0, .5, 1, 2
switch ND_Num
case 0
ND_col = 1;
case .5
ND_col = 2;
case 1
ND_col = 3;
case 2
ND_col = 4;
end
%LATEST from 08/09/2023
box(1).rs = [ 1.0 1.0 1.0 1.0
1.05 1.101 1.14 1.14
0.803 1.12 1.54 4.17
0.645 0.788 0.929 2.82];
box(2).rs = [1.0 1.0 1.0 1
0.296 0.312 0.325 0.424
0.331 0.457 0.632 1.735
0.245 0.294 0.348 1.077];
SR(1:fix(k/2),1:fix(l/2)) = box(box_Num).rs(1,ND_col);
SR(1:fix(k/2),fix(l/2)+1:l) = box(box_Num).rs(2,ND_col);
SR(fix(k/2)+1:k,1:fix(l/2)) = box(box_Num).rs(3,ND_col);
SR(fix(k/2)+1:k,fix(l/2)+1:l) = box(box_Num).rs(4,ND_col);
hotspot=hotspot_ob./SR;
[V_lt,H_lt]=find_max(hotspot_ob,1,fix(k/2),1,fix(l/2));
%V_lt=140;H_lt=166;
[V_rt,H_rt]=find_max(hotspot_ob,1,fix(k/2),fix(l/2)+1,l);
[V_ld,H_ld]=find_max(hotspot_ob,fix(k/2)+1,k,1,fix(l/2));
[V_rd,H_rd]=find_max(hotspot_ob,fix(k/2)+1,k,fix(l/2)+1,l);
%%find max for hotspot for later T correction Jie add on Mar2216, two ways:
%%neigther seem to work properly
%1st find the strongest point and make it as threshold–find corresponding
%intensities in other quadrants
hotspot_lt = hotspot(1:fix(k/2),1:fix(l/2)); [k_lt, l_lt] = size(hotspot_lt);
hotspot_rt = hotspot(1:fix(k/2),(fix(l/2)+1):l); [k_rt, l_rt] = size(hotspot_rt);
hotspot_ld = hotspot((fix(k/2)+1):k,1:fix(l/2)); [k_ld, l_ld] = size(hotspot_ld);
hotspot_rd = hotspot((fix(k/2)+1):k,(fix(l/2)+1):l); [k_rd, l_rd] = size(hotspot_rd);
[m_lt,n_lt]=find_max(hotspot_lt,1,k_lt,1,l_lt);
[m_rt,n_rt]=find_max(hotspot_rt,1,k_rt,1,l_rt);
[m_ld,n_ld]=find_max(hotspot_ld,1,k_ld,1,l_ld);
[m_rd,n_rd]=find_max(hotspot_rd,1,k_rd,1,l_rd);
misfit = zeros(4,1);
misfit(1,1) = (hotspot_rt(m_rt,n_rt)-hotspot_rt(m_lt,n_lt)).^2+(hotspot_ld(m_ld,n_ld)-hotspot_ld(m_lt,n_lt)).^2 …
+(hotspot_rd(m_rd,n_rd)-hotspot_rd(m_lt,n_lt)).^2;
misfit(2,1) = (hotspot_lt(m_rt,n_rt)-hotspot_lt(m_rt,n_rt)).^2+(hotspot_ld(m_rt,n_rt)-hotspot_ld(m_rt,n_rt)).^2 …
+(hotspot_rd(m_rt,n_rt)-hotspot_rd(m_rt,n_rt)).^2;
misfit(3,1) = (hotspot_lt(m_ld,n_ld)-hotspot_lt(m_ld,n_ld)).^2+(hotspot_rt(m_ld,n_ld)-hotspot_rt(m_ld,n_ld)).^2 …
+(hotspot_rd(m_ld,n_ld)-hotspot_rd(m_ld,n_ld)).^2;
misfit(4,1) = (hotspot_lt(m_rd,n_rd)-hotspot_ld(m_rd,n_rd)).^2+(hotspot_rt(m_rd,n_rd)-hotspot_rt(m_rd,n_rd)).^2 …
+(hotspot_ld(m_rd,n_rd)-hotspot_ld(m_rd,n_rd)).^2;
switch min(misfit)
case misfit(1,1)
mm = m_lt; nn = n_lt;
case misfit(2,1)
mm = m_rt; nn = n_rt;
case misfit(3,1)
mm = m_ld; nn = n_ld;
case misfit(4,1)
mm = m_rd; nn = n_rd;
end
Max_color = [hotspot_lt(mm,nn) hotspot_rt(mm,nn) hotspot_ld(mm,nn) hotspot_rd(mm,nn)]
m = min([k_lt;k_rt;k_ld;k_rd]); n = min([l_lt;l_rt;l_ld;l_rd]);
misfit2 = zeros(m,n);
for countm = 1:m
for countn = 1:n
misfit2(countm,countn) = (hotspot_lt(countm,countn)-hotspot_lt(m_lt,n_lt)).^2 + (hotspot_rt(countm,countn)-hotspot_rt(m_rt,n_rt)).^2 …
+(hotspot_ld(countm,countn)-hotspot_ld(m_ld,n_ld)).^2+(hotspot_rd(countm,countn)-hotspot_rd(m_rd,n_rd)).^2;
end
end
for countm = 1:m
for countn = 1:n
if misfit2(countm,countn) == min(min(misfit2))
mmm = countm; nnn = countn;
end
end
end
Max_color2 = [hotspot_lt(mmm,nnn) hotspot_rt(mmm,nnn) hotspot_ld(mmm,nnn) hotspot_rd(mmm,nnn)]
%%
center_LT=[V_lt,H_lt];
center_LD=[V_ld,H_ld];
center_RT=[V_rt,H_rt];
center_RD=[V_rd,H_rd];
% Define the bounds of the matrix
k_max = size(hotspot, 1);
l_max = size(hotspot, 2);
% Ensure the indices are within valid bounds
V_lt_start = max(V_lt-hscale, 1);
V_lt_end = min(V_lt+hscale, k_max);
H_lt_start = max(H_lt-hscale, 1);
H_lt_end = min(H_lt+hscale, l_max);
V_ld_start = max(V_ld-hscale, 1);
V_ld_end = min(V_ld+hscale, k_max);
H_ld_start = max(H_ld-hscale, 1);
H_ld_end = min(H_ld+hscale, l_max);
V_rt_start = max(V_rt-hscale, 1);
V_rt_end = min(V_rt+hscale, k_max);
H_rt_start = max(H_rt-hscale, 1);
H_rt_end = min(H_rt+hscale, l_max);
V_rd_start = max(V_rd-hscale, 1);
V_rd_end = min(V_rd+hscale, k_max);
H_rd_start = max(H_rd-hscale, 1);
H_rd_end = min(H_rd+hscale, l_max);
% Now extract the subarrays with valid indices
LT = hotspot(V_lt_start:V_lt_end, H_lt_start:H_lt_end);
LD = hotspot(V_ld_start:V_ld_end, H_ld_start:H_ld_end);
RT = hotspot(V_rt_start:V_rt_end, H_rt_start:H_rt_end);
RD = hotspot(V_rd_start:V_rd_end, H_rd_start:H_rd_end);
% Find New centers and update them
[center_RT_new,Cor_RT] = imagematching (hotspot,LT,center_RT,scale); % use LT as target image
[center_LD_new,Cor_LD] = imagematching (hotspot,LT,center_LD,scale);
[center_RD_new,Cor_RD] = imagematching (hotspot,LT,center_RD,scale);
center_LD=center_LD_new;
center_RT=center_RT_new;
center_RD=center_RD_new;
[inter_center_RT,Cor_RT] = intermatching (hotspot,LT,center_RT_new,scale,subpixel);
[inter_center_LD,Cor_LD] = intermatching (hotspot,LT,center_LD_new,scale,subpixel);
[inter_center_RD,Cor_RD] = intermatching (hotspot,LT,center_RD_new,scale,subpixel);
center_LD=inter_center_LD;
center_RT=inter_center_RT;
center_RD=inter_center_RD;
Cor=[1 Cor_RT;Cor_LD Cor_RD];
V_ld=center_LD(1,1); H_ld=center_LD(1,2);
V_rt=center_RT(1,1); H_rt=center_RT(1,2);
V_rd=center_RD(1,1); H_rd=center_RD(1,2);
[XI_ld,YI_ld]=meshgrid(H_ld-hscale:H_ld+hscale,V_ld-hscale:V_ld+hscale);
[XI_rt,YI_rt]=meshgrid(H_rt-hscale:H_rt+hscale,V_rt-hscale:V_rt+hscale);
[XI_rd,YI_rd]=meshgrid(H_rd-hscale:H_rd+hscale,V_rd-hscale:V_rd+hscale);
LD=interp2(hotspot,XI_ld,YI_ld); % update images
RT=interp2(hotspot,XI_rt,YI_rt);
RD=interp2(hotspot,XI_rd,YI_rd);
lamda_LT=580*10^(-9);
lamda_RT=640*10^(-9);
lamda_LD=766*10^(-9);
lamda_RD=905*10^(-9);
planck=6.6*10^(-34);
Kb=1.38*10^(-23);
c=3*10^8;
Wien_LT=Kb/planck/c*log(2*pi*planck*c*c./LT/lamda_LT^5);
Wien_RT=Kb/planck/c*log(2*pi*planck*c*c./RT/lamda_RT^5);
Wien_LD=Kb/planck/c*log(2*pi*planck*c*c./LD/lamda_LD^5);
Wien_RD=Kb/planck/c*log(2*pi*planck*c*c./RD/lamda_RD^5);
[m,n]=size(LT);
for i=1:m
for j=1:n
X=[1/lamda_LT 1/lamda_RT 1/lamda_LD 1/lamda_RD]’;
% X=[1/lamda_650 1/lamda_800 1/lamda_900]’;
X_reg=[X ones(size(X))];
Y=[Wien_LT(i,j) Wien_RT(i,j) Wien_LD(i,j) Wien_RD(i,j)]’;
% Y=[Wien_LT(i,j) Wien_LD(i,j) Wien_RD(i,j)]’;
%R(i,j)=corrcoef(X,Y);
[T_inv,bint]=regress(Y,X_reg); %% bint is 95% confidence level of T
R(i,j)=corr(X,Y);
T(i,j)=1/T_inv(1,1); %% T_inv(1,1) is for T
Em(i,j)=exp(-T_inv(2,1)*planck*c/Kb); %% T_inv(2,1) is for emissivity
T_err(i,j)=(1/bint(1,1)-1/bint(1,2))/2; %% difference between upper limit of T – lower limit of T
T_low(i,j)=1/bint(1,2);
T_high(i,j)=1/bint(1,1);
end
end
%% max in four regimes Jie add on Dec 5th 2015
[max_LT,Indexing] = max(LT(:))
max_RD = max(max(RD));max_LD = max(max(LD));max_RT = max(max(RT));
Max_color4 = [LT(Indexing) RT(Indexing) LD(Indexing) RD(Indexing)]
%% max grid search Jie add on April 1st
[m,n]=size(RD);
misfit3 = zeros(m,n);
for countm = 1:m
for countn = 1:n
misfit3(countm,countn) = (LT(countm,countn)-max_LT).^2 + (RT(countm,countn)-max_RT).^2 …
+(LD(countm,countn)-max_LD).^2+(RD(countm,countn)-max_RD).^2;
end
end
for countm = 1:m
for countn = 1:n
if misfit3(countm,countn) == min(min(misfit3))
m4 = countm; n4 = countn;
end
end
end
Max_color3 = [LT(m4,n4) RT(m4,n4) LD(m4,n4) RD(m4,n4)];
Max_Ih = [LT(m4,:); RT(m4,:); LD(m4,:); RD(m4,:)];
Max_Iv = [LT(:,n4)’; RT(:,n4)’; LD(:,n4)’; RD(:,n4)’];
%%
figure(‘Name’,’hotspot’);
imagesc(hotspot_ob);
figure(‘Name’,’hot spot in 4 regions’);
subplot(2,2,1)
imagesc(LT);
subplot(2,2,2)
imagesc(RT);
subplot(2,2,3)
imagesc(LD);
subplot(2,2,4)
imagesc(RD);
figure(‘Name’,’T profile (pixel)’);
imagesc(T);
[Max_T, H]=max(max(T)); % maximum Temperature, horizontal position
[Max_T, V]=max(max(T’)); % maximum Temperature, vertical position
grid=0.48; % each pixel is 0.5um
X_position=(-H+1)*grid: grid: (scale-H+1)*grid;
figure(‘Name’,’Hirizontal T profile throughh highest T point’)
plot (X_position, T(V, :));
title(‘horizotal plot’)
xlabel(‘horizontal positon/um’)
ylabel (‘temperature/K’);
figure(‘Name’,’Vertical T profile throughh highest T point’)
Y_position=(-V+1)*grid: grid: (scale-V+1)*grid;
plot(Y_position,T(:,H));
title(‘Vertical plot’)
xlabel(‘Vertical positon/um’)
ylabel (‘temperature/K’);
[Y_p,X_p]=meshgrid(X_position, Y_position);
figure(‘Name’,’3D T profile’)
surf(X_p,Y_p,T);
xlabel(‘Horizontal distance(um)’)
ylabel (‘Vetical distance(um)’);
zlabel(‘Temperature(K)’)
shading interp;
figure(‘Name’,’T profile (pixel)’);
imagesc(X_position,Y_position,T);
xlabel(‘Horizontal distance(um)’)
ylabel (‘Vetical distance(um)’);
colormap(‘turbo’)
colorbar;
figure(‘Name’,’T profile (pixel) contour’);
imagesc(X_position,Y_position,T);
xlabel(‘Horizontal distance(um)’)
ylabel (‘Vetical distance(um)’);
colormap(‘turbo’)
colorbar;
hold on; % Keep the image displayed while adding contour
contour(X_position, Y_position, T, 10, ‘LineWidth’, 1, ‘LineColor’, ‘w’); % 40 contours, white lines
hold off; % Release the hold on the current figure
figure(‘Name’,’T error’);
imagesc(X_position,Y_position,T_err);
figure(‘Name’,’Emissivity Profile’)
imagesc(X_position,Y_position,log10(Em));
figure(‘Name’,’3D Emissivity profile’)
surf(X_p,Y_p,log10(Em));
H=scale/2; V=scale/2;% give the point needed to plot T cross section
figure(‘Name’,’Vertical Em/Emax vs T trough highest T point’)
plot(T(:,H),Em(:,H)/max(Em(:,H)),’–rs’);
title(‘Vertical plot’)
xlabel(‘Temperature’)
ylabel (‘Em/Em_max’);
figure(‘Name’,’horizontal Em/Emax vs T trough highest T point’)
plot(T(V,:),Em(V,:)/max(Em(V,:)),’–rs’);
title(‘horizontal Em/Emax vs T’)
xlabel(‘Temperature’)
ylabel (‘Em/Em_max’);
% figure(12); % 3D image for intensity in 4 regions
% subplot(2,2,1)
% surf(X_p,Y_p,LT);
% subplot(2,2,2)
% surf(X_p,Y_p,RT);
% subplot(2,2,3)
% surf(X_p,Y_p,LD);
% subplot(2,2,4)
% surf(X_p,Y_p,RD)
figure (‘Name’,’Emissivity vs T over whole space’); plot(T,Em);
Image result:
2nd code:
clear; close all
[filename, pathname, filterindex]=uigetfile(‘*.txt’, ‘Enter input data file..’);
fullname=fullfile(pathname, filename);
mydata=importdata(fullname);
hotspot_ob=double(mydata);
scale=120;
subpixel=4;
hscale=scale/2;
[k,l]=size(hotspot_ob);
SR=ones(size(hotspot_ob));
box_Num = 1; % box 1 or 2
ND_Num = 0; % 0, .5, 1, 2
switch ND_Num
case 0
ND_col = 1;
case .5
ND_col = 2;
case 1
ND_col = 3;
case 2
ND_col = 4;
end
%LATEST from 08/09/2023
box(1).rs = [ 1.0 1.0 1.0 1.0
1.05 1.101 1.14 1.14
0.803 1.12 1.54 4.17
0.645 0.788 0.929 2.82];
box(2).rs = [1.0 1.0 1.0 1
0.296 0.312 0.325 0.424
0.331 0.457 0.632 1.735
0.245 0.294 0.348 1.077];
SR(1:fix(k/2),1:fix(l/2)) = box(box_Num).rs(1,ND_col);
SR(1:fix(k/2),fix(l/2)+1:l) = box(box_Num).rs(2,ND_col);
SR(fix(k/2)+1:k,1:fix(l/2)) = box(box_Num).rs(3,ND_col);
SR(fix(k/2)+1:k,fix(l/2)+1:l) = box(box_Num).rs(4,ND_col);
hotspot=hotspot_ob./SR;
[V_lt,H_lt]=find_max(hotspot_ob,1,fix(k/2),1,fix(l/2));
[V_rt,H_rt]=find_max(hotspot_ob,1,fix(k/2),fix(l/2)+1,l);
[V_ld,H_ld]=find_max(hotspot_ob,fix(k/2)+1,k,1,fix(l/2));
[V_rd,H_rd]=find_max(hotspot_ob,fix(k/2)+1,k,fix(l/2)+1,l);
hotspot_lt = hotspot(1:fix(k/2),1:fix(l/2)); [k_lt, l_lt] = size(hotspot_lt);
hotspot_rt = hotspot(1:fix(k/2),(fix(l/2)+1):l); [k_rt, l_rt] = size(hotspot_rt);
hotspot_ld = hotspot((fix(k/2)+1):k,1:fix(l/2)); [k_ld, l_ld] = size(hotspot_ld);
hotspot_rd = hotspot((fix(k/2)+1):k,(fix(l/2)+1):l); [k_rd, l_rd] = size(hotspot_rd);
%V_lt=98; H_lt=150;
[m_lt,n_lt]=find_max(hotspot_lt,1,k_lt,1,l_lt);
[m_rt,n_rt]=find_max(hotspot_rt,1,k_rt,1,l_rt);
[m_ld,n_ld]=find_max(hotspot_ld,1,k_ld,1,l_ld);
[m_rd,n_rd]=find_max(hotspot_rd,1,k_rd,1,l_rd);
misfit = zeros(4,1);
misfit(1,1) = (hotspot_rt(m_rt,n_rt)-hotspot_rt(m_lt,n_lt)).^2+(hotspot_ld(m_ld,n_ld)-hotspot_ld(m_lt,n_lt)).^2 …
+(hotspot_rd(m_rd,n_rd)-hotspot_rd(m_lt,n_lt)).^2;
misfit(2,1) = (hotspot_lt(m_rt,n_rt)-hotspot_lt(m_rt,n_rt)).^2+(hotspot_ld(m_rt,n_rt)-hotspot_ld(m_rt,n_rt)).^2 …
+(hotspot_rd(m_rt,n_rt)-hotspot_rd(m_rt,n_rt)).^2;
misfit(3,1) = (hotspot_lt(m_ld,n_ld)-hotspot_lt(m_ld,n_ld)).^2+(hotspot_rt(m_ld,n_ld)-hotspot_rt(m_ld,n_ld)).^2 …
+(hotspot_rd(m_ld,n_ld)-hotspot_rd(m_ld,n_ld)).^2;
misfit(4,1) = (hotspot_lt(m_rd,n_rd)-hotspot_ld(m_rd,n_rd)).^2+(hotspot_rt(m_rd,n_rd)-hotspot_rt(m_rd,n_rd)).^2 …
+(hotspot_ld(m_rd,n_rd)-hotspot_ld(m_rd,n_rd)).^2;
switch min(misfit)
case misfit(1,1)
mm = m_lt; nn = n_lt;
case misfit(2,1)
mm = m_rt; nn = n_rt;
case misfit(3,1)
mm = m_ld; nn = n_ld;
case misfit(4,1)
mm = m_rd; nn = n_rd;
end
Max_color = [ hotspot_rt(mm,nn) hotspot_ld(mm,nn) hotspot_rd(mm,nn)]
m = min([k_lt;k_rt;k_ld;k_rd]); n = min([l_lt;l_rt;l_ld;l_rd]);
misfit2 = zeros(m,n);
for countm = 1:m
for countn = 1:n
misfit2(countm,countn) = (hotspot_rt(countm,countn)-hotspot_rt(m_rt,n_rt)).^2 …
+(hotspot_ld(countm,countn)-hotspot_ld(m_ld,n_ld)).^2+(hotspot_rd(countm,countn)-hotspot_rd(m_rd,n_rd)).^2;
end
end
for countm = 1:m
for countn = 1:n
if misfit2(countm,countn) == min(min(misfit2))
mmm = countm; nnn = countn;
end
end
end
Max_color2 = [hotspot_rt(mmm,nnn) hotspot_ld(mmm,nnn) hotspot_rd(mmm,nnn)]
%V_lt=126; H_lt=176;
%V_rt=125; H_rt=565;
%V_ld=398; H_ld=179;
%V_rd=388; H_rd=580;
center_LT=[V_lt,H_lt];
center_LD=[V_ld, H_ld];
center_RT=[V_rt,H_rt];
center_RD=[V_rd,H_rd];
LT=hotspot(V_lt-hscale:V_lt+hscale,H_lt-hscale:H_lt+hscale);
LD=hotspot(V_ld-hscale:V_ld+hscale,H_ld-hscale:H_ld+hscale);
RT=hotspot(V_rt-hscale:V_rt+hscale,H_rt-hscale:H_rt+hscale);
RD=hotspot(V_rd-hscale:V_rd+hscale,H_rd-hscale:H_rd+hscale);
% Find New centers and update them
[center_LT_new,Cor_LT] = imagematching (hotspot,RD,center_RT,scale); % use RT as target image
[center_LD_new,Cor_LD] = imagematching (hotspot,RD,center_LD,scale);
[center_RT_new,Cor_RT] = imagematching (hotspot,RD,center_RD,scale);
center_LD=center_LD_new;
center_LT=center_LT_new;
center_RT=center_RT_new;
[inter_center_LT,Cor_LT] = intermatching (hotspot,RD,center_LT_new,scale,subpixel);
[inter_center_LD,Cor_LD] = intermatching (hotspot,RD,center_LD_new,scale,subpixel);
[inter_center_RT,Cor_RT] = intermatching (hotspot,RD,center_RT_new,scale,subpixel);
center_LD=inter_center_LD;
center_LT=inter_center_LT;
center_RT=inter_center_RT;
Cor=[1 Cor_LT;Cor_LD Cor_RT];
V_ld=center_LD(1,1); H_ld=center_LD(1,2);
V_rt=center_LT(1,1); H_lt=center_LT(1,2);
V_rd=center_RD(1,1); H_rd=center_RD(1,2);
[XI_ld,YI_ld]=meshgrid(H_ld-hscale:H_ld+hscale,V_ld-hscale:V_ld+hscale);
[XI_lt,YI_lt]=meshgrid(H_lt-hscale:H_lt+hscale,V_lt-hscale:V_lt+hscale);
[XI_rd,YI_rd]=meshgrid(H_rd-hscale:H_rd+hscale,V_rd-hscale:V_rd+hscale);
LD=interp2(hotspot,XI_ld,YI_ld,’spline’); % update images
LT=interp2(hotspot,XI_lt,YI_lt,’spline’);
RD=interp2(hotspot,XI_rd,YI_rd,’spline’);
% Assuming you want to exclude 580 nm
lamda_LT=580*10^(-9);
lamda_RT=640*10^(-9);
lamda_LD=766*10^(-9);
lamda_RD=905*10^(-9);
planck=6.6*10^(-34);
Kb=1.38*10^(-23);
c=3*10^8;
%Wien_LT=Kb/planck/c*log(2*pi*planck*c*c./LT/lamda_LT^5);
Wien_RT=Kb/planck/c*log(2*pi*planck*c*c./RT/lamda_RT^5);
Wien_LD=Kb/planck/c*log(2*pi*planck*c*c./LD/lamda_LD^5);
Wien_RD=Kb/planck/c*log(2*pi*planck*c*c./RD/lamda_RD^5);
[m,n]=size(LD);
for i=1:m
for j=1:n
X=[1/lamda_RT 1/lamda_LD 1/lamda_RD]’;
%X=[1/lamda_650 1/lamda_800 1/lamda_900]’;
X_reg=[X ones(size(X))];
%Y=[Wien_LT(i,j) Wien_LD(i,j) Wien_RD(i,j)]’;
Y=[Wien_RT(i,j) Wien_LD(i,j) Wien_RD(i,j)]’;
%R(i,j)=corrcoef(X,Y);
[T_inv,bint]=regress(Y,X_reg);
R(i,j)=corr(X,Y);
T(i,j)=1/T_inv(1,1);
Em(i,j)=exp(-T_inv(2,1)*planck*c/Kb);
T_err(i,j)=(1/bint(1,1)-1/bint(1,2))/2;
T_low(i,j)=1/bint(1,2);
T_high(i,j)=1/bint(1,1);
end
end
%% max in four regimes Jie add on Dec 5th 2015
[max_RD,Indexing] = max(RD(:))
max_LD = max(max(LD));max_RT = max(max(RT));
Max_color4 = [RT(Indexing) LD(Indexing) RD(Indexing)]
%% max grid search Jie add on April 1st
[m,n]=size(RD);
misfit3 = zeros(m,n);
for countm = 1:m
for countn = 1:n
misfit3(countm,countn) = (RT(countm,countn)-max_RT).^2 …
+(LD(countm,countn)-max_LD).^2+(RD(countm,countn)-max_RD).^2;
end
end
for countm = 1:m
for countn = 1:n
if misfit3(countm,countn) == min(min(misfit3))
m4 = countm; n4 = countn;
end
end
end
Max_color3 = [ RT(m4,n4) LD(m4,n4) RD(m4,n4)];
Max_Ih = [ RT(m4,:); LD(m4,:); RD(m4,:)];
Max_Iv = [ RT(:,n4)’; LD(:,n4)’; RD(:,n4)’];
figure(‘Name’,’hotspot’);
imagesc(hotspot_ob);
figure(‘Name’,’hot spot in 4 regions’);
subplot(2,2,2)
imagesc(RT);
subplot(2,2,3)
imagesc(LD);
subplot(2,2,4)
imagesc(RD);
figure(‘Name’,’T profile (pixel)’);
imagesc(T);
[Max_T, H]=max(max(T)); % maximum Temperature, horizontal position
[Max_T, V]=max(max(T’)); % maximum Temperature, vertical position
grid=0.48; % each pixel is 0.5um
X_position=(-H+1)*grid: grid: (scale-H+1)*grid;
figure(‘Name’,’Hirizontal T profile throughh highest T point’)
plot (X_position, T(V, :));
title(‘horizotal plot’)
xlabel(‘horizontal positon/um’)
ylabel (‘temperature/K’);
figure(‘Name’,’Vertical T profile throughh highest T point’)
Y_position=(-V+1)*grid: grid: (scale-V+1)*grid;
plot(Y_position,T(:,H));
title(‘Vertical plot’)
xlabel(‘Vertical positon/um’)
ylabel (‘temperature/K’);
[Y_p,X_p]=meshgrid(X_position, Y_position);
figure(‘Name’,’3D T profile’)
surf(X_p,Y_p,T);
xlabel(‘Horizontal distance(um)’)
ylabel (‘Vetical distance(um)’);
zlabel(‘Temperature(K)’)
shading interp;
figure(‘Name’,’T profile (pixel)’);
imagesc(X_position,Y_position,T);
xlabel(‘Horizontal distance(um)’)
ylabel (‘Vetical distance(um)’);
colormap(‘turbo’)
colorbar;
figure(‘Name’,’T profile (pixel) contour’);
imagesc(X_position,Y_position,T);
xlabel(‘Horizontal distance(um)’)
ylabel (‘Vetical distance(um)’);
colormap(‘turbo’)
colorbar;
hold on; % Keep the image displayed while adding contour
contour(X_position, Y_position, T, 10, ‘LineWidth’, 1, ‘LineColor’, ‘w’); % 40 contours, white lines
hold off; % Release the hold on the current figure
figure(‘Name’,’T error’);
imagesc(X_position,Y_position,T_err);
figure(‘Name’,’Emissivity Profile’)
imagesc(X_position,Y_position,log10(Em));
figure(‘Name’,’3D Emissivity profile’)
surf(X_p,Y_p,log10(Em));
H=scale/2; V=scale/2;% give the point needed to plot T cross section
figure(‘Name’,’Vertical Em/Emax vs T trough highest T point’)
plot(T(:,H),Em(:,H)/max(Em(:,H)),’–rs’);
title(‘Vertical plot’)
xlabel(‘Temperature’)
ylabel (‘Em/Em_max’);
figure(‘Name’,’horizontal Em/Emax vs T trough highest T point’)
plot(T(V,:),Em(V,:)/max(Em(V,:)),’–rs’);
title(‘horizontal Em/Emax vs T’)
xlabel(‘Temperature’)
ylabel (‘Em/Em_max’);
% figure(12); % 3D image for intensity in 4 regions
% subplot(2,2,1)
% surf(X_p,Y_p,LT);
% subplot(2,2,2)
% surf(X_p,Y_p,RT);
% subplot(2,2,3)
% surf(X_p,Y_p,LD);
% subplot(2,2,4)
% surf(X_p,Y_p,RD)
figure (‘Name’,’Emissivity vs T over whole space’); plot(T,Em);
image result: So, I do research of laser heating metals. We have this code (main code) that separates each hotspot into different qudrants to analyze. Occacsionally, one quadrant nees to be excluded from the calculations (2nd code). So the main code, uses the LT (left top) as the focus for analyzing. The 2nd code, needs to do the analysis with LD (Left down) as the focus instead adn exclude everything that has to do with LT.
So the issue is: the tempeartures calculated from the 2nd code are 300 to 400 K too low. (pics of ffure with each code.). If you have any isight I would greatly appreciate it!
Here is the normal code:
clear;close all;
[filename, pathname, filterindex] = uigetfile(‘*.txt’, ‘Enter input data file..’);
fullname = fullfile(pathname, filename);
mydata = importdata(fullname);
hotspot_ob=double(mydata);
scale= 120; % size of the box 90*90
subpixel=4;
hscale=scale/2;
[k,l]=size(hotspot_ob);
SR=ones(size(hotspot_ob));
box_Num = 1; % box 1 or 2
ND_Num = 0; % 0, .5, 1, 2
switch ND_Num
case 0
ND_col = 1;
case .5
ND_col = 2;
case 1
ND_col = 3;
case 2
ND_col = 4;
end
%LATEST from 08/09/2023
box(1).rs = [ 1.0 1.0 1.0 1.0
1.05 1.101 1.14 1.14
0.803 1.12 1.54 4.17
0.645 0.788 0.929 2.82];
box(2).rs = [1.0 1.0 1.0 1
0.296 0.312 0.325 0.424
0.331 0.457 0.632 1.735
0.245 0.294 0.348 1.077];
SR(1:fix(k/2),1:fix(l/2)) = box(box_Num).rs(1,ND_col);
SR(1:fix(k/2),fix(l/2)+1:l) = box(box_Num).rs(2,ND_col);
SR(fix(k/2)+1:k,1:fix(l/2)) = box(box_Num).rs(3,ND_col);
SR(fix(k/2)+1:k,fix(l/2)+1:l) = box(box_Num).rs(4,ND_col);
hotspot=hotspot_ob./SR;
[V_lt,H_lt]=find_max(hotspot_ob,1,fix(k/2),1,fix(l/2));
%V_lt=140;H_lt=166;
[V_rt,H_rt]=find_max(hotspot_ob,1,fix(k/2),fix(l/2)+1,l);
[V_ld,H_ld]=find_max(hotspot_ob,fix(k/2)+1,k,1,fix(l/2));
[V_rd,H_rd]=find_max(hotspot_ob,fix(k/2)+1,k,fix(l/2)+1,l);
%%find max for hotspot for later T correction Jie add on Mar2216, two ways:
%%neigther seem to work properly
%1st find the strongest point and make it as threshold–find corresponding
%intensities in other quadrants
hotspot_lt = hotspot(1:fix(k/2),1:fix(l/2)); [k_lt, l_lt] = size(hotspot_lt);
hotspot_rt = hotspot(1:fix(k/2),(fix(l/2)+1):l); [k_rt, l_rt] = size(hotspot_rt);
hotspot_ld = hotspot((fix(k/2)+1):k,1:fix(l/2)); [k_ld, l_ld] = size(hotspot_ld);
hotspot_rd = hotspot((fix(k/2)+1):k,(fix(l/2)+1):l); [k_rd, l_rd] = size(hotspot_rd);
[m_lt,n_lt]=find_max(hotspot_lt,1,k_lt,1,l_lt);
[m_rt,n_rt]=find_max(hotspot_rt,1,k_rt,1,l_rt);
[m_ld,n_ld]=find_max(hotspot_ld,1,k_ld,1,l_ld);
[m_rd,n_rd]=find_max(hotspot_rd,1,k_rd,1,l_rd);
misfit = zeros(4,1);
misfit(1,1) = (hotspot_rt(m_rt,n_rt)-hotspot_rt(m_lt,n_lt)).^2+(hotspot_ld(m_ld,n_ld)-hotspot_ld(m_lt,n_lt)).^2 …
+(hotspot_rd(m_rd,n_rd)-hotspot_rd(m_lt,n_lt)).^2;
misfit(2,1) = (hotspot_lt(m_rt,n_rt)-hotspot_lt(m_rt,n_rt)).^2+(hotspot_ld(m_rt,n_rt)-hotspot_ld(m_rt,n_rt)).^2 …
+(hotspot_rd(m_rt,n_rt)-hotspot_rd(m_rt,n_rt)).^2;
misfit(3,1) = (hotspot_lt(m_ld,n_ld)-hotspot_lt(m_ld,n_ld)).^2+(hotspot_rt(m_ld,n_ld)-hotspot_rt(m_ld,n_ld)).^2 …
+(hotspot_rd(m_ld,n_ld)-hotspot_rd(m_ld,n_ld)).^2;
misfit(4,1) = (hotspot_lt(m_rd,n_rd)-hotspot_ld(m_rd,n_rd)).^2+(hotspot_rt(m_rd,n_rd)-hotspot_rt(m_rd,n_rd)).^2 …
+(hotspot_ld(m_rd,n_rd)-hotspot_ld(m_rd,n_rd)).^2;
switch min(misfit)
case misfit(1,1)
mm = m_lt; nn = n_lt;
case misfit(2,1)
mm = m_rt; nn = n_rt;
case misfit(3,1)
mm = m_ld; nn = n_ld;
case misfit(4,1)
mm = m_rd; nn = n_rd;
end
Max_color = [hotspot_lt(mm,nn) hotspot_rt(mm,nn) hotspot_ld(mm,nn) hotspot_rd(mm,nn)]
m = min([k_lt;k_rt;k_ld;k_rd]); n = min([l_lt;l_rt;l_ld;l_rd]);
misfit2 = zeros(m,n);
for countm = 1:m
for countn = 1:n
misfit2(countm,countn) = (hotspot_lt(countm,countn)-hotspot_lt(m_lt,n_lt)).^2 + (hotspot_rt(countm,countn)-hotspot_rt(m_rt,n_rt)).^2 …
+(hotspot_ld(countm,countn)-hotspot_ld(m_ld,n_ld)).^2+(hotspot_rd(countm,countn)-hotspot_rd(m_rd,n_rd)).^2;
end
end
for countm = 1:m
for countn = 1:n
if misfit2(countm,countn) == min(min(misfit2))
mmm = countm; nnn = countn;
end
end
end
Max_color2 = [hotspot_lt(mmm,nnn) hotspot_rt(mmm,nnn) hotspot_ld(mmm,nnn) hotspot_rd(mmm,nnn)]
%%
center_LT=[V_lt,H_lt];
center_LD=[V_ld,H_ld];
center_RT=[V_rt,H_rt];
center_RD=[V_rd,H_rd];
% Define the bounds of the matrix
k_max = size(hotspot, 1);
l_max = size(hotspot, 2);
% Ensure the indices are within valid bounds
V_lt_start = max(V_lt-hscale, 1);
V_lt_end = min(V_lt+hscale, k_max);
H_lt_start = max(H_lt-hscale, 1);
H_lt_end = min(H_lt+hscale, l_max);
V_ld_start = max(V_ld-hscale, 1);
V_ld_end = min(V_ld+hscale, k_max);
H_ld_start = max(H_ld-hscale, 1);
H_ld_end = min(H_ld+hscale, l_max);
V_rt_start = max(V_rt-hscale, 1);
V_rt_end = min(V_rt+hscale, k_max);
H_rt_start = max(H_rt-hscale, 1);
H_rt_end = min(H_rt+hscale, l_max);
V_rd_start = max(V_rd-hscale, 1);
V_rd_end = min(V_rd+hscale, k_max);
H_rd_start = max(H_rd-hscale, 1);
H_rd_end = min(H_rd+hscale, l_max);
% Now extract the subarrays with valid indices
LT = hotspot(V_lt_start:V_lt_end, H_lt_start:H_lt_end);
LD = hotspot(V_ld_start:V_ld_end, H_ld_start:H_ld_end);
RT = hotspot(V_rt_start:V_rt_end, H_rt_start:H_rt_end);
RD = hotspot(V_rd_start:V_rd_end, H_rd_start:H_rd_end);
% Find New centers and update them
[center_RT_new,Cor_RT] = imagematching (hotspot,LT,center_RT,scale); % use LT as target image
[center_LD_new,Cor_LD] = imagematching (hotspot,LT,center_LD,scale);
[center_RD_new,Cor_RD] = imagematching (hotspot,LT,center_RD,scale);
center_LD=center_LD_new;
center_RT=center_RT_new;
center_RD=center_RD_new;
[inter_center_RT,Cor_RT] = intermatching (hotspot,LT,center_RT_new,scale,subpixel);
[inter_center_LD,Cor_LD] = intermatching (hotspot,LT,center_LD_new,scale,subpixel);
[inter_center_RD,Cor_RD] = intermatching (hotspot,LT,center_RD_new,scale,subpixel);
center_LD=inter_center_LD;
center_RT=inter_center_RT;
center_RD=inter_center_RD;
Cor=[1 Cor_RT;Cor_LD Cor_RD];
V_ld=center_LD(1,1); H_ld=center_LD(1,2);
V_rt=center_RT(1,1); H_rt=center_RT(1,2);
V_rd=center_RD(1,1); H_rd=center_RD(1,2);
[XI_ld,YI_ld]=meshgrid(H_ld-hscale:H_ld+hscale,V_ld-hscale:V_ld+hscale);
[XI_rt,YI_rt]=meshgrid(H_rt-hscale:H_rt+hscale,V_rt-hscale:V_rt+hscale);
[XI_rd,YI_rd]=meshgrid(H_rd-hscale:H_rd+hscale,V_rd-hscale:V_rd+hscale);
LD=interp2(hotspot,XI_ld,YI_ld); % update images
RT=interp2(hotspot,XI_rt,YI_rt);
RD=interp2(hotspot,XI_rd,YI_rd);
lamda_LT=580*10^(-9);
lamda_RT=640*10^(-9);
lamda_LD=766*10^(-9);
lamda_RD=905*10^(-9);
planck=6.6*10^(-34);
Kb=1.38*10^(-23);
c=3*10^8;
Wien_LT=Kb/planck/c*log(2*pi*planck*c*c./LT/lamda_LT^5);
Wien_RT=Kb/planck/c*log(2*pi*planck*c*c./RT/lamda_RT^5);
Wien_LD=Kb/planck/c*log(2*pi*planck*c*c./LD/lamda_LD^5);
Wien_RD=Kb/planck/c*log(2*pi*planck*c*c./RD/lamda_RD^5);
[m,n]=size(LT);
for i=1:m
for j=1:n
X=[1/lamda_LT 1/lamda_RT 1/lamda_LD 1/lamda_RD]’;
% X=[1/lamda_650 1/lamda_800 1/lamda_900]’;
X_reg=[X ones(size(X))];
Y=[Wien_LT(i,j) Wien_RT(i,j) Wien_LD(i,j) Wien_RD(i,j)]’;
% Y=[Wien_LT(i,j) Wien_LD(i,j) Wien_RD(i,j)]’;
%R(i,j)=corrcoef(X,Y);
[T_inv,bint]=regress(Y,X_reg); %% bint is 95% confidence level of T
R(i,j)=corr(X,Y);
T(i,j)=1/T_inv(1,1); %% T_inv(1,1) is for T
Em(i,j)=exp(-T_inv(2,1)*planck*c/Kb); %% T_inv(2,1) is for emissivity
T_err(i,j)=(1/bint(1,1)-1/bint(1,2))/2; %% difference between upper limit of T – lower limit of T
T_low(i,j)=1/bint(1,2);
T_high(i,j)=1/bint(1,1);
end
end
%% max in four regimes Jie add on Dec 5th 2015
[max_LT,Indexing] = max(LT(:))
max_RD = max(max(RD));max_LD = max(max(LD));max_RT = max(max(RT));
Max_color4 = [LT(Indexing) RT(Indexing) LD(Indexing) RD(Indexing)]
%% max grid search Jie add on April 1st
[m,n]=size(RD);
misfit3 = zeros(m,n);
for countm = 1:m
for countn = 1:n
misfit3(countm,countn) = (LT(countm,countn)-max_LT).^2 + (RT(countm,countn)-max_RT).^2 …
+(LD(countm,countn)-max_LD).^2+(RD(countm,countn)-max_RD).^2;
end
end
for countm = 1:m
for countn = 1:n
if misfit3(countm,countn) == min(min(misfit3))
m4 = countm; n4 = countn;
end
end
end
Max_color3 = [LT(m4,n4) RT(m4,n4) LD(m4,n4) RD(m4,n4)];
Max_Ih = [LT(m4,:); RT(m4,:); LD(m4,:); RD(m4,:)];
Max_Iv = [LT(:,n4)’; RT(:,n4)’; LD(:,n4)’; RD(:,n4)’];
%%
figure(‘Name’,’hotspot’);
imagesc(hotspot_ob);
figure(‘Name’,’hot spot in 4 regions’);
subplot(2,2,1)
imagesc(LT);
subplot(2,2,2)
imagesc(RT);
subplot(2,2,3)
imagesc(LD);
subplot(2,2,4)
imagesc(RD);
figure(‘Name’,’T profile (pixel)’);
imagesc(T);
[Max_T, H]=max(max(T)); % maximum Temperature, horizontal position
[Max_T, V]=max(max(T’)); % maximum Temperature, vertical position
grid=0.48; % each pixel is 0.5um
X_position=(-H+1)*grid: grid: (scale-H+1)*grid;
figure(‘Name’,’Hirizontal T profile throughh highest T point’)
plot (X_position, T(V, :));
title(‘horizotal plot’)
xlabel(‘horizontal positon/um’)
ylabel (‘temperature/K’);
figure(‘Name’,’Vertical T profile throughh highest T point’)
Y_position=(-V+1)*grid: grid: (scale-V+1)*grid;
plot(Y_position,T(:,H));
title(‘Vertical plot’)
xlabel(‘Vertical positon/um’)
ylabel (‘temperature/K’);
[Y_p,X_p]=meshgrid(X_position, Y_position);
figure(‘Name’,’3D T profile’)
surf(X_p,Y_p,T);
xlabel(‘Horizontal distance(um)’)
ylabel (‘Vetical distance(um)’);
zlabel(‘Temperature(K)’)
shading interp;
figure(‘Name’,’T profile (pixel)’);
imagesc(X_position,Y_position,T);
xlabel(‘Horizontal distance(um)’)
ylabel (‘Vetical distance(um)’);
colormap(‘turbo’)
colorbar;
figure(‘Name’,’T profile (pixel) contour’);
imagesc(X_position,Y_position,T);
xlabel(‘Horizontal distance(um)’)
ylabel (‘Vetical distance(um)’);
colormap(‘turbo’)
colorbar;
hold on; % Keep the image displayed while adding contour
contour(X_position, Y_position, T, 10, ‘LineWidth’, 1, ‘LineColor’, ‘w’); % 40 contours, white lines
hold off; % Release the hold on the current figure
figure(‘Name’,’T error’);
imagesc(X_position,Y_position,T_err);
figure(‘Name’,’Emissivity Profile’)
imagesc(X_position,Y_position,log10(Em));
figure(‘Name’,’3D Emissivity profile’)
surf(X_p,Y_p,log10(Em));
H=scale/2; V=scale/2;% give the point needed to plot T cross section
figure(‘Name’,’Vertical Em/Emax vs T trough highest T point’)
plot(T(:,H),Em(:,H)/max(Em(:,H)),’–rs’);
title(‘Vertical plot’)
xlabel(‘Temperature’)
ylabel (‘Em/Em_max’);
figure(‘Name’,’horizontal Em/Emax vs T trough highest T point’)
plot(T(V,:),Em(V,:)/max(Em(V,:)),’–rs’);
title(‘horizontal Em/Emax vs T’)
xlabel(‘Temperature’)
ylabel (‘Em/Em_max’);
% figure(12); % 3D image for intensity in 4 regions
% subplot(2,2,1)
% surf(X_p,Y_p,LT);
% subplot(2,2,2)
% surf(X_p,Y_p,RT);
% subplot(2,2,3)
% surf(X_p,Y_p,LD);
% subplot(2,2,4)
% surf(X_p,Y_p,RD)
figure (‘Name’,’Emissivity vs T over whole space’); plot(T,Em);
Image result:
2nd code:
clear; close all
[filename, pathname, filterindex]=uigetfile(‘*.txt’, ‘Enter input data file..’);
fullname=fullfile(pathname, filename);
mydata=importdata(fullname);
hotspot_ob=double(mydata);
scale=120;
subpixel=4;
hscale=scale/2;
[k,l]=size(hotspot_ob);
SR=ones(size(hotspot_ob));
box_Num = 1; % box 1 or 2
ND_Num = 0; % 0, .5, 1, 2
switch ND_Num
case 0
ND_col = 1;
case .5
ND_col = 2;
case 1
ND_col = 3;
case 2
ND_col = 4;
end
%LATEST from 08/09/2023
box(1).rs = [ 1.0 1.0 1.0 1.0
1.05 1.101 1.14 1.14
0.803 1.12 1.54 4.17
0.645 0.788 0.929 2.82];
box(2).rs = [1.0 1.0 1.0 1
0.296 0.312 0.325 0.424
0.331 0.457 0.632 1.735
0.245 0.294 0.348 1.077];
SR(1:fix(k/2),1:fix(l/2)) = box(box_Num).rs(1,ND_col);
SR(1:fix(k/2),fix(l/2)+1:l) = box(box_Num).rs(2,ND_col);
SR(fix(k/2)+1:k,1:fix(l/2)) = box(box_Num).rs(3,ND_col);
SR(fix(k/2)+1:k,fix(l/2)+1:l) = box(box_Num).rs(4,ND_col);
hotspot=hotspot_ob./SR;
[V_lt,H_lt]=find_max(hotspot_ob,1,fix(k/2),1,fix(l/2));
[V_rt,H_rt]=find_max(hotspot_ob,1,fix(k/2),fix(l/2)+1,l);
[V_ld,H_ld]=find_max(hotspot_ob,fix(k/2)+1,k,1,fix(l/2));
[V_rd,H_rd]=find_max(hotspot_ob,fix(k/2)+1,k,fix(l/2)+1,l);
hotspot_lt = hotspot(1:fix(k/2),1:fix(l/2)); [k_lt, l_lt] = size(hotspot_lt);
hotspot_rt = hotspot(1:fix(k/2),(fix(l/2)+1):l); [k_rt, l_rt] = size(hotspot_rt);
hotspot_ld = hotspot((fix(k/2)+1):k,1:fix(l/2)); [k_ld, l_ld] = size(hotspot_ld);
hotspot_rd = hotspot((fix(k/2)+1):k,(fix(l/2)+1):l); [k_rd, l_rd] = size(hotspot_rd);
%V_lt=98; H_lt=150;
[m_lt,n_lt]=find_max(hotspot_lt,1,k_lt,1,l_lt);
[m_rt,n_rt]=find_max(hotspot_rt,1,k_rt,1,l_rt);
[m_ld,n_ld]=find_max(hotspot_ld,1,k_ld,1,l_ld);
[m_rd,n_rd]=find_max(hotspot_rd,1,k_rd,1,l_rd);
misfit = zeros(4,1);
misfit(1,1) = (hotspot_rt(m_rt,n_rt)-hotspot_rt(m_lt,n_lt)).^2+(hotspot_ld(m_ld,n_ld)-hotspot_ld(m_lt,n_lt)).^2 …
+(hotspot_rd(m_rd,n_rd)-hotspot_rd(m_lt,n_lt)).^2;
misfit(2,1) = (hotspot_lt(m_rt,n_rt)-hotspot_lt(m_rt,n_rt)).^2+(hotspot_ld(m_rt,n_rt)-hotspot_ld(m_rt,n_rt)).^2 …
+(hotspot_rd(m_rt,n_rt)-hotspot_rd(m_rt,n_rt)).^2;
misfit(3,1) = (hotspot_lt(m_ld,n_ld)-hotspot_lt(m_ld,n_ld)).^2+(hotspot_rt(m_ld,n_ld)-hotspot_rt(m_ld,n_ld)).^2 …
+(hotspot_rd(m_ld,n_ld)-hotspot_rd(m_ld,n_ld)).^2;
misfit(4,1) = (hotspot_lt(m_rd,n_rd)-hotspot_ld(m_rd,n_rd)).^2+(hotspot_rt(m_rd,n_rd)-hotspot_rt(m_rd,n_rd)).^2 …
+(hotspot_ld(m_rd,n_rd)-hotspot_ld(m_rd,n_rd)).^2;
switch min(misfit)
case misfit(1,1)
mm = m_lt; nn = n_lt;
case misfit(2,1)
mm = m_rt; nn = n_rt;
case misfit(3,1)
mm = m_ld; nn = n_ld;
case misfit(4,1)
mm = m_rd; nn = n_rd;
end
Max_color = [ hotspot_rt(mm,nn) hotspot_ld(mm,nn) hotspot_rd(mm,nn)]
m = min([k_lt;k_rt;k_ld;k_rd]); n = min([l_lt;l_rt;l_ld;l_rd]);
misfit2 = zeros(m,n);
for countm = 1:m
for countn = 1:n
misfit2(countm,countn) = (hotspot_rt(countm,countn)-hotspot_rt(m_rt,n_rt)).^2 …
+(hotspot_ld(countm,countn)-hotspot_ld(m_ld,n_ld)).^2+(hotspot_rd(countm,countn)-hotspot_rd(m_rd,n_rd)).^2;
end
end
for countm = 1:m
for countn = 1:n
if misfit2(countm,countn) == min(min(misfit2))
mmm = countm; nnn = countn;
end
end
end
Max_color2 = [hotspot_rt(mmm,nnn) hotspot_ld(mmm,nnn) hotspot_rd(mmm,nnn)]
%V_lt=126; H_lt=176;
%V_rt=125; H_rt=565;
%V_ld=398; H_ld=179;
%V_rd=388; H_rd=580;
center_LT=[V_lt,H_lt];
center_LD=[V_ld, H_ld];
center_RT=[V_rt,H_rt];
center_RD=[V_rd,H_rd];
LT=hotspot(V_lt-hscale:V_lt+hscale,H_lt-hscale:H_lt+hscale);
LD=hotspot(V_ld-hscale:V_ld+hscale,H_ld-hscale:H_ld+hscale);
RT=hotspot(V_rt-hscale:V_rt+hscale,H_rt-hscale:H_rt+hscale);
RD=hotspot(V_rd-hscale:V_rd+hscale,H_rd-hscale:H_rd+hscale);
% Find New centers and update them
[center_LT_new,Cor_LT] = imagematching (hotspot,RD,center_RT,scale); % use RT as target image
[center_LD_new,Cor_LD] = imagematching (hotspot,RD,center_LD,scale);
[center_RT_new,Cor_RT] = imagematching (hotspot,RD,center_RD,scale);
center_LD=center_LD_new;
center_LT=center_LT_new;
center_RT=center_RT_new;
[inter_center_LT,Cor_LT] = intermatching (hotspot,RD,center_LT_new,scale,subpixel);
[inter_center_LD,Cor_LD] = intermatching (hotspot,RD,center_LD_new,scale,subpixel);
[inter_center_RT,Cor_RT] = intermatching (hotspot,RD,center_RT_new,scale,subpixel);
center_LD=inter_center_LD;
center_LT=inter_center_LT;
center_RT=inter_center_RT;
Cor=[1 Cor_LT;Cor_LD Cor_RT];
V_ld=center_LD(1,1); H_ld=center_LD(1,2);
V_rt=center_LT(1,1); H_lt=center_LT(1,2);
V_rd=center_RD(1,1); H_rd=center_RD(1,2);
[XI_ld,YI_ld]=meshgrid(H_ld-hscale:H_ld+hscale,V_ld-hscale:V_ld+hscale);
[XI_lt,YI_lt]=meshgrid(H_lt-hscale:H_lt+hscale,V_lt-hscale:V_lt+hscale);
[XI_rd,YI_rd]=meshgrid(H_rd-hscale:H_rd+hscale,V_rd-hscale:V_rd+hscale);
LD=interp2(hotspot,XI_ld,YI_ld,’spline’); % update images
LT=interp2(hotspot,XI_lt,YI_lt,’spline’);
RD=interp2(hotspot,XI_rd,YI_rd,’spline’);
% Assuming you want to exclude 580 nm
lamda_LT=580*10^(-9);
lamda_RT=640*10^(-9);
lamda_LD=766*10^(-9);
lamda_RD=905*10^(-9);
planck=6.6*10^(-34);
Kb=1.38*10^(-23);
c=3*10^8;
%Wien_LT=Kb/planck/c*log(2*pi*planck*c*c./LT/lamda_LT^5);
Wien_RT=Kb/planck/c*log(2*pi*planck*c*c./RT/lamda_RT^5);
Wien_LD=Kb/planck/c*log(2*pi*planck*c*c./LD/lamda_LD^5);
Wien_RD=Kb/planck/c*log(2*pi*planck*c*c./RD/lamda_RD^5);
[m,n]=size(LD);
for i=1:m
for j=1:n
X=[1/lamda_RT 1/lamda_LD 1/lamda_RD]’;
%X=[1/lamda_650 1/lamda_800 1/lamda_900]’;
X_reg=[X ones(size(X))];
%Y=[Wien_LT(i,j) Wien_LD(i,j) Wien_RD(i,j)]’;
Y=[Wien_RT(i,j) Wien_LD(i,j) Wien_RD(i,j)]’;
%R(i,j)=corrcoef(X,Y);
[T_inv,bint]=regress(Y,X_reg);
R(i,j)=corr(X,Y);
T(i,j)=1/T_inv(1,1);
Em(i,j)=exp(-T_inv(2,1)*planck*c/Kb);
T_err(i,j)=(1/bint(1,1)-1/bint(1,2))/2;
T_low(i,j)=1/bint(1,2);
T_high(i,j)=1/bint(1,1);
end
end
%% max in four regimes Jie add on Dec 5th 2015
[max_RD,Indexing] = max(RD(:))
max_LD = max(max(LD));max_RT = max(max(RT));
Max_color4 = [RT(Indexing) LD(Indexing) RD(Indexing)]
%% max grid search Jie add on April 1st
[m,n]=size(RD);
misfit3 = zeros(m,n);
for countm = 1:m
for countn = 1:n
misfit3(countm,countn) = (RT(countm,countn)-max_RT).^2 …
+(LD(countm,countn)-max_LD).^2+(RD(countm,countn)-max_RD).^2;
end
end
for countm = 1:m
for countn = 1:n
if misfit3(countm,countn) == min(min(misfit3))
m4 = countm; n4 = countn;
end
end
end
Max_color3 = [ RT(m4,n4) LD(m4,n4) RD(m4,n4)];
Max_Ih = [ RT(m4,:); LD(m4,:); RD(m4,:)];
Max_Iv = [ RT(:,n4)’; LD(:,n4)’; RD(:,n4)’];
figure(‘Name’,’hotspot’);
imagesc(hotspot_ob);
figure(‘Name’,’hot spot in 4 regions’);
subplot(2,2,2)
imagesc(RT);
subplot(2,2,3)
imagesc(LD);
subplot(2,2,4)
imagesc(RD);
figure(‘Name’,’T profile (pixel)’);
imagesc(T);
[Max_T, H]=max(max(T)); % maximum Temperature, horizontal position
[Max_T, V]=max(max(T’)); % maximum Temperature, vertical position
grid=0.48; % each pixel is 0.5um
X_position=(-H+1)*grid: grid: (scale-H+1)*grid;
figure(‘Name’,’Hirizontal T profile throughh highest T point’)
plot (X_position, T(V, :));
title(‘horizotal plot’)
xlabel(‘horizontal positon/um’)
ylabel (‘temperature/K’);
figure(‘Name’,’Vertical T profile throughh highest T point’)
Y_position=(-V+1)*grid: grid: (scale-V+1)*grid;
plot(Y_position,T(:,H));
title(‘Vertical plot’)
xlabel(‘Vertical positon/um’)
ylabel (‘temperature/K’);
[Y_p,X_p]=meshgrid(X_position, Y_position);
figure(‘Name’,’3D T profile’)
surf(X_p,Y_p,T);
xlabel(‘Horizontal distance(um)’)
ylabel (‘Vetical distance(um)’);
zlabel(‘Temperature(K)’)
shading interp;
figure(‘Name’,’T profile (pixel)’);
imagesc(X_position,Y_position,T);
xlabel(‘Horizontal distance(um)’)
ylabel (‘Vetical distance(um)’);
colormap(‘turbo’)
colorbar;
figure(‘Name’,’T profile (pixel) contour’);
imagesc(X_position,Y_position,T);
xlabel(‘Horizontal distance(um)’)
ylabel (‘Vetical distance(um)’);
colormap(‘turbo’)
colorbar;
hold on; % Keep the image displayed while adding contour
contour(X_position, Y_position, T, 10, ‘LineWidth’, 1, ‘LineColor’, ‘w’); % 40 contours, white lines
hold off; % Release the hold on the current figure
figure(‘Name’,’T error’);
imagesc(X_position,Y_position,T_err);
figure(‘Name’,’Emissivity Profile’)
imagesc(X_position,Y_position,log10(Em));
figure(‘Name’,’3D Emissivity profile’)
surf(X_p,Y_p,log10(Em));
H=scale/2; V=scale/2;% give the point needed to plot T cross section
figure(‘Name’,’Vertical Em/Emax vs T trough highest T point’)
plot(T(:,H),Em(:,H)/max(Em(:,H)),’–rs’);
title(‘Vertical plot’)
xlabel(‘Temperature’)
ylabel (‘Em/Em_max’);
figure(‘Name’,’horizontal Em/Emax vs T trough highest T point’)
plot(T(V,:),Em(V,:)/max(Em(V,:)),’–rs’);
title(‘horizontal Em/Emax vs T’)
xlabel(‘Temperature’)
ylabel (‘Em/Em_max’);
% figure(12); % 3D image for intensity in 4 regions
% subplot(2,2,1)
% surf(X_p,Y_p,LT);
% subplot(2,2,2)
% surf(X_p,Y_p,RT);
% subplot(2,2,3)
% surf(X_p,Y_p,LD);
% subplot(2,2,4)
% surf(X_p,Y_p,RD)
figure (‘Name’,’Emissivity vs T over whole space’); plot(T,Em);
image result: colormap, contour, image analysis MATLAB Answers — New Questions
Find limits satisfying a condition on an integral
I have some data that I have interpolated with even spacing from measured data. I can integrate this between defined limits etc using trapz. However, I want to turn the problem on its head and find for what limit does the result of definite integral satisfy a condition. As an example:
x = linspace(0, 2*pi, 20);
y = sin(x);
lowLimIndex = 1;
upLimIndex = find(x>pi,1);
halfInt = trapz(x(lowLimIndex:upLimIndex),y(lowLimIndex:upLimIndex))
Or close enough to the known result of 2… But in my case, I effectively want to find the value of x that results in the integral = 2.
I could fit an equation to my data and use solve to solve it in symbolic mode I suppose…. Seems there ought to be a way to do this using the optimization tools though?
Any help appreciated!I have some data that I have interpolated with even spacing from measured data. I can integrate this between defined limits etc using trapz. However, I want to turn the problem on its head and find for what limit does the result of definite integral satisfy a condition. As an example:
x = linspace(0, 2*pi, 20);
y = sin(x);
lowLimIndex = 1;
upLimIndex = find(x>pi,1);
halfInt = trapz(x(lowLimIndex:upLimIndex),y(lowLimIndex:upLimIndex))
Or close enough to the known result of 2… But in my case, I effectively want to find the value of x that results in the integral = 2.
I could fit an equation to my data and use solve to solve it in symbolic mode I suppose…. Seems there ought to be a way to do this using the optimization tools though?
Any help appreciated! I have some data that I have interpolated with even spacing from measured data. I can integrate this between defined limits etc using trapz. However, I want to turn the problem on its head and find for what limit does the result of definite integral satisfy a condition. As an example:
x = linspace(0, 2*pi, 20);
y = sin(x);
lowLimIndex = 1;
upLimIndex = find(x>pi,1);
halfInt = trapz(x(lowLimIndex:upLimIndex),y(lowLimIndex:upLimIndex))
Or close enough to the known result of 2… But in my case, I effectively want to find the value of x that results in the integral = 2.
I could fit an equation to my data and use solve to solve it in symbolic mode I suppose…. Seems there ought to be a way to do this using the optimization tools though?
Any help appreciated! definite integral, optimization MATLAB Answers — New Questions
How to use nohup feature in MATLAB with Linux-based OS
I have been curious to understand the usage of the nohup feature in MATLAB with a Linux-based OS. While I have attempted to find answers to my questions on the internet, the instructions provided by users can be quite confusing to follow. It would be greatly appreciated if someone could assist me in resolving the following queries.
How to execute a MATLAB script file with nohup feature?
How to know if the MATLAB script is being executed on nohup command?
How to stop executing the MATLAB script midway, in case you start it by mistake?
Indeed, the queries and answers provided in this thread form a comprehensive guide for MATLAB users.I have been curious to understand the usage of the nohup feature in MATLAB with a Linux-based OS. While I have attempted to find answers to my questions on the internet, the instructions provided by users can be quite confusing to follow. It would be greatly appreciated if someone could assist me in resolving the following queries.
How to execute a MATLAB script file with nohup feature?
How to know if the MATLAB script is being executed on nohup command?
How to stop executing the MATLAB script midway, in case you start it by mistake?
Indeed, the queries and answers provided in this thread form a comprehensive guide for MATLAB users. I have been curious to understand the usage of the nohup feature in MATLAB with a Linux-based OS. While I have attempted to find answers to my questions on the internet, the instructions provided by users can be quite confusing to follow. It would be greatly appreciated if someone could assist me in resolving the following queries.
How to execute a MATLAB script file with nohup feature?
How to know if the MATLAB script is being executed on nohup command?
How to stop executing the MATLAB script midway, in case you start it by mistake?
Indeed, the queries and answers provided in this thread form a comprehensive guide for MATLAB users. matlab, linux, nohup, gui MATLAB Answers — New Questions
Error using build after clibgen.generateLibraryDefinition runs as expected.
I’m attempting to follow a tutorial for interfacing with C++ libraries in MATLAB. The only major difference between my situation and the author’s is that I’m working on a windows machine, meaning that I run
> cl /c rectangle.cpp
> log /OUT:rectangle.lib rectangle.obj
to compile into a .obj file (rather than .o) and reformat it to .lib. Then, in the MATLAB environment, I run
>> headerFile = "C:pathtorectangle.h";
>> libFile = "C:pathtorectangle.lib";
>> libName = "rectangle";
>> clibgen.generateLibraryDefinition(headerFile, "Libraries", libFile, "PackageName", libName)
This runs without issue. The generated definerectangle.m looks as I expect, and the summary looks as follows:
>> summary(definerectangle)
MATLAB Interface to rectangle Library
Class clib.rectangle.Rectangle
Constructors:
clib.rectangle.Rectangle(double,double,double,double)
clib.rectangle.Rectangle(clib.rectangle.Rectangle)
Methods:
double Area()
No Properties defined
which seems right. However, when I attempt to build, I get the following result
>> build(definerectangle)
Building interface file ‘rectangleInterface.dll’ for clib interface ‘rectangle’.
Not enough input arguments.
Error in clibgen.internal.build>delAdditionalFiles (line 1001)
for ind = 1:length(cmdFilesList)
^^^^^^^^^^^^
Error in clibgen.internal.build (line 378)
delAdditionalFiles(outputDir, srcFileName, dataFileName, buildExecutable, sourceFilesObj, ”);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in clibgen.internal.buildHelper (line 104)
[status,cmdOut] = clibgen.internal.build(srcFile,cellstr(libraries),cellstr(srcFiles),cellstr(includePath),interfaceDir,obj.DefinedMacros,obj.UndefinedMacros, …
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in clibgen.LibraryDefinition/build (line 1664)
clibgen.internal.buildHelper(obj, obj.LibraryInterface, ”, directBuild);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I have checked the mex compiler configuration to see if that might be an issue, but it appears to match what I used to compile with cl.exe
>> mex -setup cpp
MEX configured to use ‘Microsoft Visual C++ 2022’ for C++ language compilation.
I’m at a loss for what this error could mean, so I would appreciate any help in interpreting it and getting this to work.I’m attempting to follow a tutorial for interfacing with C++ libraries in MATLAB. The only major difference between my situation and the author’s is that I’m working on a windows machine, meaning that I run
> cl /c rectangle.cpp
> log /OUT:rectangle.lib rectangle.obj
to compile into a .obj file (rather than .o) and reformat it to .lib. Then, in the MATLAB environment, I run
>> headerFile = "C:pathtorectangle.h";
>> libFile = "C:pathtorectangle.lib";
>> libName = "rectangle";
>> clibgen.generateLibraryDefinition(headerFile, "Libraries", libFile, "PackageName", libName)
This runs without issue. The generated definerectangle.m looks as I expect, and the summary looks as follows:
>> summary(definerectangle)
MATLAB Interface to rectangle Library
Class clib.rectangle.Rectangle
Constructors:
clib.rectangle.Rectangle(double,double,double,double)
clib.rectangle.Rectangle(clib.rectangle.Rectangle)
Methods:
double Area()
No Properties defined
which seems right. However, when I attempt to build, I get the following result
>> build(definerectangle)
Building interface file ‘rectangleInterface.dll’ for clib interface ‘rectangle’.
Not enough input arguments.
Error in clibgen.internal.build>delAdditionalFiles (line 1001)
for ind = 1:length(cmdFilesList)
^^^^^^^^^^^^
Error in clibgen.internal.build (line 378)
delAdditionalFiles(outputDir, srcFileName, dataFileName, buildExecutable, sourceFilesObj, ”);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in clibgen.internal.buildHelper (line 104)
[status,cmdOut] = clibgen.internal.build(srcFile,cellstr(libraries),cellstr(srcFiles),cellstr(includePath),interfaceDir,obj.DefinedMacros,obj.UndefinedMacros, …
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in clibgen.LibraryDefinition/build (line 1664)
clibgen.internal.buildHelper(obj, obj.LibraryInterface, ”, directBuild);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I have checked the mex compiler configuration to see if that might be an issue, but it appears to match what I used to compile with cl.exe
>> mex -setup cpp
MEX configured to use ‘Microsoft Visual C++ 2022’ for C++ language compilation.
I’m at a loss for what this error could mean, so I would appreciate any help in interpreting it and getting this to work. I’m attempting to follow a tutorial for interfacing with C++ libraries in MATLAB. The only major difference between my situation and the author’s is that I’m working on a windows machine, meaning that I run
> cl /c rectangle.cpp
> log /OUT:rectangle.lib rectangle.obj
to compile into a .obj file (rather than .o) and reformat it to .lib. Then, in the MATLAB environment, I run
>> headerFile = "C:pathtorectangle.h";
>> libFile = "C:pathtorectangle.lib";
>> libName = "rectangle";
>> clibgen.generateLibraryDefinition(headerFile, "Libraries", libFile, "PackageName", libName)
This runs without issue. The generated definerectangle.m looks as I expect, and the summary looks as follows:
>> summary(definerectangle)
MATLAB Interface to rectangle Library
Class clib.rectangle.Rectangle
Constructors:
clib.rectangle.Rectangle(double,double,double,double)
clib.rectangle.Rectangle(clib.rectangle.Rectangle)
Methods:
double Area()
No Properties defined
which seems right. However, when I attempt to build, I get the following result
>> build(definerectangle)
Building interface file ‘rectangleInterface.dll’ for clib interface ‘rectangle’.
Not enough input arguments.
Error in clibgen.internal.build>delAdditionalFiles (line 1001)
for ind = 1:length(cmdFilesList)
^^^^^^^^^^^^
Error in clibgen.internal.build (line 378)
delAdditionalFiles(outputDir, srcFileName, dataFileName, buildExecutable, sourceFilesObj, ”);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in clibgen.internal.buildHelper (line 104)
[status,cmdOut] = clibgen.internal.build(srcFile,cellstr(libraries),cellstr(srcFiles),cellstr(includePath),interfaceDir,obj.DefinedMacros,obj.UndefinedMacros, …
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in clibgen.LibraryDefinition/build (line 1664)
clibgen.internal.buildHelper(obj, obj.LibraryInterface, ”, directBuild);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I have checked the mex compiler configuration to see if that might be an issue, but it appears to match what I used to compile with cl.exe
>> mex -setup cpp
MEX configured to use ‘Microsoft Visual C++ 2022’ for C++ language compilation.
I’m at a loss for what this error could mean, so I would appreciate any help in interpreting it and getting this to work. c++, mex compiler MATLAB Answers — New Questions
Using drawpoint in 3d axes
Hello,
I have a program that plots the electrostatic potential created by electrons confined to a sphere. What I’d like to be able to do is grab one of those electrons and move it in the figure to see how the potential changes. What I’ve been able to do is project everything from the surface of the sphere onto 2D axes and use drawpoint to get the interactivity I want. However, I’m a little annoyed by the distortions inherent in the projection so before I go and add a bunch of other functionality I have in mind I want to see if I can get the interactivity while having everything remain on the sphere.
One strange thing is that while drawpoint will still create a Point object in 3D axes (constrained to z=0), it’s motion is distorted: upon clicking the point, it jumps away and will move as if constrained to a line parallel to the x- or y-axes. Once the cursor gets far enough away, however, its motion does follow the cursor, just with a constant offset. The magnitude of that offset is a function of the viewing angle: when looking straight down or up the point moves as expected, but a low angle makes the point get very confused.
The fact that the point is always on the xy-plane isn’t necessarily a deal-breaker, though I can already think of several issues. The bigger issue is of course the strange distorted motion. I assume there’s nothing I can really do to fix that, so my question is whether there might be a different way to achieve the same end – some sort of callback on a scatterplot that would update the coordinates based on the mouse position?
If not, I do have an idea for a compromise, but I figured this was interesting enough to ask.
Thanks!Hello,
I have a program that plots the electrostatic potential created by electrons confined to a sphere. What I’d like to be able to do is grab one of those electrons and move it in the figure to see how the potential changes. What I’ve been able to do is project everything from the surface of the sphere onto 2D axes and use drawpoint to get the interactivity I want. However, I’m a little annoyed by the distortions inherent in the projection so before I go and add a bunch of other functionality I have in mind I want to see if I can get the interactivity while having everything remain on the sphere.
One strange thing is that while drawpoint will still create a Point object in 3D axes (constrained to z=0), it’s motion is distorted: upon clicking the point, it jumps away and will move as if constrained to a line parallel to the x- or y-axes. Once the cursor gets far enough away, however, its motion does follow the cursor, just with a constant offset. The magnitude of that offset is a function of the viewing angle: when looking straight down or up the point moves as expected, but a low angle makes the point get very confused.
The fact that the point is always on the xy-plane isn’t necessarily a deal-breaker, though I can already think of several issues. The bigger issue is of course the strange distorted motion. I assume there’s nothing I can really do to fix that, so my question is whether there might be a different way to achieve the same end – some sort of callback on a scatterplot that would update the coordinates based on the mouse position?
If not, I do have an idea for a compromise, but I figured this was interesting enough to ask.
Thanks! Hello,
I have a program that plots the electrostatic potential created by electrons confined to a sphere. What I’d like to be able to do is grab one of those electrons and move it in the figure to see how the potential changes. What I’ve been able to do is project everything from the surface of the sphere onto 2D axes and use drawpoint to get the interactivity I want. However, I’m a little annoyed by the distortions inherent in the projection so before I go and add a bunch of other functionality I have in mind I want to see if I can get the interactivity while having everything remain on the sphere.
One strange thing is that while drawpoint will still create a Point object in 3D axes (constrained to z=0), it’s motion is distorted: upon clicking the point, it jumps away and will move as if constrained to a line parallel to the x- or y-axes. Once the cursor gets far enough away, however, its motion does follow the cursor, just with a constant offset. The magnitude of that offset is a function of the viewing angle: when looking straight down or up the point moves as expected, but a low angle makes the point get very confused.
The fact that the point is always on the xy-plane isn’t necessarily a deal-breaker, though I can already think of several issues. The bigger issue is of course the strange distorted motion. I assume there’s nothing I can really do to fix that, so my question is whether there might be a different way to achieve the same end – some sort of callback on a scatterplot that would update the coordinates based on the mouse position?
If not, I do have an idea for a compromise, but I figured this was interesting enough to ask.
Thanks! callback, 3d plots MATLAB Answers — New Questions
Unable to see uifigure object properties
Hi,
I’m very new to Matlab, I’m basically learning as I go. At the moment I’m working on getting a callback function for a group of two radio buttons to work. The aim of the buttons is to switch between a line graph and a bar graph. The buttons are created fine, and open in the figure but I can’t see the properties.
My script:
chartSwitchGroup = uibuttongroup(tab, ‘Position’, [30, screenSize(4) – 330, 1220, 40],’BorderType’,’none’);
rbLine = uiradiobutton(chartSwitchGroup, ‘Text’, ‘Line Graph’, ‘Position’, [10, 5, 105, 30], ‘Value’, true, ‘FontSize’,16);
rbBar = uiradiobutton(chartSwitchGroup, ‘Text’, ‘Bar Chart’, ‘Position’, [115, 5, 125, 30], ‘FontSize’,16);
rbBar
rbLine
Command window:
I’m just trying to see the properties, basically so I can see what they are and learn more but even when leaving the figure open, I still get the ‘no longer exists message’
rbBar =
RadioButton (Bar Chart) with properties:
Value: 0
Text: ‘Bar Chart’
Position: [115 5 125 30]
Show all properties
rbLine =
RadioButton (Line Graph) with properties:
Value: 1
Text: ‘Line Graph’
Position: [10 5 105 30]
Show all properties
Unable to display properties for variable rbLine because it no longer exists.
**EDIT: More intense googling suggests this could be something to do with nested functions? **Hi,
I’m very new to Matlab, I’m basically learning as I go. At the moment I’m working on getting a callback function for a group of two radio buttons to work. The aim of the buttons is to switch between a line graph and a bar graph. The buttons are created fine, and open in the figure but I can’t see the properties.
My script:
chartSwitchGroup = uibuttongroup(tab, ‘Position’, [30, screenSize(4) – 330, 1220, 40],’BorderType’,’none’);
rbLine = uiradiobutton(chartSwitchGroup, ‘Text’, ‘Line Graph’, ‘Position’, [10, 5, 105, 30], ‘Value’, true, ‘FontSize’,16);
rbBar = uiradiobutton(chartSwitchGroup, ‘Text’, ‘Bar Chart’, ‘Position’, [115, 5, 125, 30], ‘FontSize’,16);
rbBar
rbLine
Command window:
I’m just trying to see the properties, basically so I can see what they are and learn more but even when leaving the figure open, I still get the ‘no longer exists message’
rbBar =
RadioButton (Bar Chart) with properties:
Value: 0
Text: ‘Bar Chart’
Position: [115 5 125 30]
Show all properties
rbLine =
RadioButton (Line Graph) with properties:
Value: 1
Text: ‘Line Graph’
Position: [10 5 105 30]
Show all properties
Unable to display properties for variable rbLine because it no longer exists.
**EDIT: More intense googling suggests this could be something to do with nested functions? ** Hi,
I’m very new to Matlab, I’m basically learning as I go. At the moment I’m working on getting a callback function for a group of two radio buttons to work. The aim of the buttons is to switch between a line graph and a bar graph. The buttons are created fine, and open in the figure but I can’t see the properties.
My script:
chartSwitchGroup = uibuttongroup(tab, ‘Position’, [30, screenSize(4) – 330, 1220, 40],’BorderType’,’none’);
rbLine = uiradiobutton(chartSwitchGroup, ‘Text’, ‘Line Graph’, ‘Position’, [10, 5, 105, 30], ‘Value’, true, ‘FontSize’,16);
rbBar = uiradiobutton(chartSwitchGroup, ‘Text’, ‘Bar Chart’, ‘Position’, [115, 5, 125, 30], ‘FontSize’,16);
rbBar
rbLine
Command window:
I’m just trying to see the properties, basically so I can see what they are and learn more but even when leaving the figure open, I still get the ‘no longer exists message’
rbBar =
RadioButton (Bar Chart) with properties:
Value: 0
Text: ‘Bar Chart’
Position: [115 5 125 30]
Show all properties
rbLine =
RadioButton (Line Graph) with properties:
Value: 1
Text: ‘Line Graph’
Position: [10 5 105 30]
Show all properties
Unable to display properties for variable rbLine because it no longer exists.
**EDIT: More intense googling suggests this could be something to do with nested functions? ** properties, radio buttons MATLAB Answers — New Questions
Deriving flux and current from the manufacturers B-H curve for inputing values in saturable transformer
Hi,
I was simulating a saturable transformer. It is shown in the figure for hysteresis design tool that the curve is between flux and current. This is a bit confusing. Should we derive the flux and current values from the manufacturers B-H curve and transformer dimensions.
Thanks,Hi,
I was simulating a saturable transformer. It is shown in the figure for hysteresis design tool that the curve is between flux and current. This is a bit confusing. Should we derive the flux and current values from the manufacturers B-H curve and transformer dimensions.
Thanks, Hi,
I was simulating a saturable transformer. It is shown in the figure for hysteresis design tool that the curve is between flux and current. This is a bit confusing. Should we derive the flux and current values from the manufacturers B-H curve and transformer dimensions.
Thanks, saturable transforemer, b-h curve MATLAB Answers — New Questions
How to output text to Command Window if signal changes from 0 to 1 in Simulink
I want to output text to the command line in Simulink when a signal turns from 0 to 1.
For example, in my model, signal A is zero unless a condition is exceeded in the model, to where signal A is then turned to one. At that point, I want to write "Signal A is 1. Data is invalid" to the command window. I’m currently trying to use a MATLAB function block:
function a = fcn (u)
if u == 1
disp(‘Signal A is 1. Data is invalid’)
a = 1;
else
end
This doesn’t seem to work. any suggestions?I want to output text to the command line in Simulink when a signal turns from 0 to 1.
For example, in my model, signal A is zero unless a condition is exceeded in the model, to where signal A is then turned to one. At that point, I want to write "Signal A is 1. Data is invalid" to the command window. I’m currently trying to use a MATLAB function block:
function a = fcn (u)
if u == 1
disp(‘Signal A is 1. Data is invalid’)
a = 1;
else
end
This doesn’t seem to work. any suggestions? I want to output text to the command line in Simulink when a signal turns from 0 to 1.
For example, in my model, signal A is zero unless a condition is exceeded in the model, to where signal A is then turned to one. At that point, I want to write "Signal A is 1. Data is invalid" to the command window. I’m currently trying to use a MATLAB function block:
function a = fcn (u)
if u == 1
disp(‘Signal A is 1. Data is invalid’)
a = 1;
else
end
This doesn’t seem to work. any suggestions? simulink, if statement, command window MATLAB Answers — New Questions
How can I timeout from “fmincon” or “fminunc” in the Optimization toolbox when it gets stuck in some computation?
I would like to timeout from "fmincon" or "fminunc" in the Optimization toolbox when it gets stuck in some computation.I would like to timeout from "fmincon" or "fminunc" in the Optimization toolbox when it gets stuck in some computation. I would like to timeout from "fmincon" or "fminunc" in the Optimization toolbox when it gets stuck in some computation. fmincon, optimization, timeout MATLAB Answers — New Questions
Custom Toolbox Documentation for Nested Namespaces
I am trying to create a custom toolbox which has multiple, sometimes nested, namespaces. How do I structure my *.mlx help files such that they appear for all functions within the toolbox.
For example, say my toolbox has the form:
└───root
├───+toolbox
│ ├───+subpackage1
│ │ └───+subpackage3
│ │ myfcn.m
│ │
│ └───+subpackage2
└───doc
GettingStarted.mlx
I am able to run
doc toolbox
and recieve the "GettingStarted.mlx"
However, how can I structure documentation such that:
doc toolbox.subpackage1.subpackage2.myfcn
returns a *.mlx for myfcn?
Currently, the output is identical to help toolbox.subpackage1.subpackage2.myfcn
Attempted Solution:
I have tried to add this documentation as follows:
└───root
├───+toolbox
│ ├───+subpackage1
│ │ └───+subpackage3
│ │ myfcn.m
│ │
│ └───+subpackage2
└───doc
│ GettingStarted.mlx
│
└───toolbox
└───subpackage1
└───subpackage3
myfcn.mlx
However, the deeply nested documentation is not found. If I manually add ‘myfcn.mlx’ into the package Examples, it shows up in the documentation under the heading ‘subpackage3’, but this is not my desired behavior. I would like to maintain the entire tree in my documentation.
I have found packages discussing using info.xml & helptoc.xml, but it is not clear how to modify these for this situation. The documentation for these files can be found here: https://www.mathworks.com/help/matlab/matlab_prog/display-custom-documentation.htmlI am trying to create a custom toolbox which has multiple, sometimes nested, namespaces. How do I structure my *.mlx help files such that they appear for all functions within the toolbox.
For example, say my toolbox has the form:
└───root
├───+toolbox
│ ├───+subpackage1
│ │ └───+subpackage3
│ │ myfcn.m
│ │
│ └───+subpackage2
└───doc
GettingStarted.mlx
I am able to run
doc toolbox
and recieve the "GettingStarted.mlx"
However, how can I structure documentation such that:
doc toolbox.subpackage1.subpackage2.myfcn
returns a *.mlx for myfcn?
Currently, the output is identical to help toolbox.subpackage1.subpackage2.myfcn
Attempted Solution:
I have tried to add this documentation as follows:
└───root
├───+toolbox
│ ├───+subpackage1
│ │ └───+subpackage3
│ │ myfcn.m
│ │
│ └───+subpackage2
└───doc
│ GettingStarted.mlx
│
└───toolbox
└───subpackage1
└───subpackage3
myfcn.mlx
However, the deeply nested documentation is not found. If I manually add ‘myfcn.mlx’ into the package Examples, it shows up in the documentation under the heading ‘subpackage3’, but this is not my desired behavior. I would like to maintain the entire tree in my documentation.
I have found packages discussing using info.xml & helptoc.xml, but it is not clear how to modify these for this situation. The documentation for these files can be found here: https://www.mathworks.com/help/matlab/matlab_prog/display-custom-documentation.html I am trying to create a custom toolbox which has multiple, sometimes nested, namespaces. How do I structure my *.mlx help files such that they appear for all functions within the toolbox.
For example, say my toolbox has the form:
└───root
├───+toolbox
│ ├───+subpackage1
│ │ └───+subpackage3
│ │ myfcn.m
│ │
│ └───+subpackage2
└───doc
GettingStarted.mlx
I am able to run
doc toolbox
and recieve the "GettingStarted.mlx"
However, how can I structure documentation such that:
doc toolbox.subpackage1.subpackage2.myfcn
returns a *.mlx for myfcn?
Currently, the output is identical to help toolbox.subpackage1.subpackage2.myfcn
Attempted Solution:
I have tried to add this documentation as follows:
└───root
├───+toolbox
│ ├───+subpackage1
│ │ └───+subpackage3
│ │ myfcn.m
│ │
│ └───+subpackage2
└───doc
│ GettingStarted.mlx
│
└───toolbox
└───subpackage1
└───subpackage3
myfcn.mlx
However, the deeply nested documentation is not found. If I manually add ‘myfcn.mlx’ into the package Examples, it shows up in the documentation under the heading ‘subpackage3’, but this is not my desired behavior. I would like to maintain the entire tree in my documentation.
I have found packages discussing using info.xml & helptoc.xml, but it is not clear how to modify these for this situation. The documentation for these files can be found here: https://www.mathworks.com/help/matlab/matlab_prog/display-custom-documentation.html matlab, toolbox MATLAB Answers — New Questions
How to store count pixel in 3D viewing
Hi all,
I have one set of 3D images Dicom. below is one of the slices.
ok, lets look the the 3D image dicom here, the location (148, 109) have count is 323.
then after did the code below,
% For binary images (png format, each pixel just have value 1 and 0.)
clc
clear all
dataSetDir = fullfile(‘C:UsersAkmalDesktopI-131 256 28.02.2020I-131 SPECT NEMA VALIDATION 01112019 256X256 26.09.2021 petang’);
imageDir = fullfile(dataSetDir,’bnwaftersegmentation’);
imds = imageDatastore(imageDir);
for i = 1:3
% subplot(6,7,i)
I = readimage(imds,i);
% binary
Is{i} = logical(I);
end
% For 3D images spect
myFolder = (‘C:UsersAkmalDesktopI-131 256 28.02.2020I-131 SPECT NEMA VALIDATION 01112019 256X256 26.09.2021 petangdcmoriextract’);
filePattern = fullfile(myFolder, ‘*.dcm’); % Change to whatever pattern you need.
theFiles = dir(filePattern);
for K = 1 : length(theFiles)
baseFileName = theFiles(K).name;
fullFileName = fullfile(theFiles(K).folder, baseFileName);
fprintf(1, ‘Now reading %sn’, fullFileName);
% Now do whatever you want with this file name,
% such as reading it in as an image array with imread()
P(:,:,K) = double(dicomread(fullFileName));
P(:,:,K) = double(P(:,:,K)) .* double( Is{K} );
end
%for viewing as 3D images
Ds = smooth3(P);
figure
hiso = patch(isosurface(Ds,5),…
‘FaceColor’,[1,.75,.65],…
‘EdgeColor’,’none’);
hcap = patch(isocaps(P,5),…
‘FaceColor’,’interp’,…
‘EdgeColor’,’none’);
colormap copper
view(45,30)
axis tight
daspect([1,1,.8])
lightangle(45,30);
set(gcf,’Renderer’,’zbuffer’); lighting phong
isonormals(Ds,hiso)
set(hcap,’AmbientStrength’,.6)
set(hiso,’SpecularColorReflectance’,0,’SpecularExponent’,50)
the 3D viewing like below. But, if you look at the same coordinate, (148, 109), its not show the count itself (332). its show the z coordinate. How to do for the 3D viewing(isosurface) can stored also the counts itself (332)??Hi all,
I have one set of 3D images Dicom. below is one of the slices.
ok, lets look the the 3D image dicom here, the location (148, 109) have count is 323.
then after did the code below,
% For binary images (png format, each pixel just have value 1 and 0.)
clc
clear all
dataSetDir = fullfile(‘C:UsersAkmalDesktopI-131 256 28.02.2020I-131 SPECT NEMA VALIDATION 01112019 256X256 26.09.2021 petang’);
imageDir = fullfile(dataSetDir,’bnwaftersegmentation’);
imds = imageDatastore(imageDir);
for i = 1:3
% subplot(6,7,i)
I = readimage(imds,i);
% binary
Is{i} = logical(I);
end
% For 3D images spect
myFolder = (‘C:UsersAkmalDesktopI-131 256 28.02.2020I-131 SPECT NEMA VALIDATION 01112019 256X256 26.09.2021 petangdcmoriextract’);
filePattern = fullfile(myFolder, ‘*.dcm’); % Change to whatever pattern you need.
theFiles = dir(filePattern);
for K = 1 : length(theFiles)
baseFileName = theFiles(K).name;
fullFileName = fullfile(theFiles(K).folder, baseFileName);
fprintf(1, ‘Now reading %sn’, fullFileName);
% Now do whatever you want with this file name,
% such as reading it in as an image array with imread()
P(:,:,K) = double(dicomread(fullFileName));
P(:,:,K) = double(P(:,:,K)) .* double( Is{K} );
end
%for viewing as 3D images
Ds = smooth3(P);
figure
hiso = patch(isosurface(Ds,5),…
‘FaceColor’,[1,.75,.65],…
‘EdgeColor’,’none’);
hcap = patch(isocaps(P,5),…
‘FaceColor’,’interp’,…
‘EdgeColor’,’none’);
colormap copper
view(45,30)
axis tight
daspect([1,1,.8])
lightangle(45,30);
set(gcf,’Renderer’,’zbuffer’); lighting phong
isonormals(Ds,hiso)
set(hcap,’AmbientStrength’,.6)
set(hiso,’SpecularColorReflectance’,0,’SpecularExponent’,50)
the 3D viewing like below. But, if you look at the same coordinate, (148, 109), its not show the count itself (332). its show the z coordinate. How to do for the 3D viewing(isosurface) can stored also the counts itself (332)?? Hi all,
I have one set of 3D images Dicom. below is one of the slices.
ok, lets look the the 3D image dicom here, the location (148, 109) have count is 323.
then after did the code below,
% For binary images (png format, each pixel just have value 1 and 0.)
clc
clear all
dataSetDir = fullfile(‘C:UsersAkmalDesktopI-131 256 28.02.2020I-131 SPECT NEMA VALIDATION 01112019 256X256 26.09.2021 petang’);
imageDir = fullfile(dataSetDir,’bnwaftersegmentation’);
imds = imageDatastore(imageDir);
for i = 1:3
% subplot(6,7,i)
I = readimage(imds,i);
% binary
Is{i} = logical(I);
end
% For 3D images spect
myFolder = (‘C:UsersAkmalDesktopI-131 256 28.02.2020I-131 SPECT NEMA VALIDATION 01112019 256X256 26.09.2021 petangdcmoriextract’);
filePattern = fullfile(myFolder, ‘*.dcm’); % Change to whatever pattern you need.
theFiles = dir(filePattern);
for K = 1 : length(theFiles)
baseFileName = theFiles(K).name;
fullFileName = fullfile(theFiles(K).folder, baseFileName);
fprintf(1, ‘Now reading %sn’, fullFileName);
% Now do whatever you want with this file name,
% such as reading it in as an image array with imread()
P(:,:,K) = double(dicomread(fullFileName));
P(:,:,K) = double(P(:,:,K)) .* double( Is{K} );
end
%for viewing as 3D images
Ds = smooth3(P);
figure
hiso = patch(isosurface(Ds,5),…
‘FaceColor’,[1,.75,.65],…
‘EdgeColor’,’none’);
hcap = patch(isocaps(P,5),…
‘FaceColor’,’interp’,…
‘EdgeColor’,’none’);
colormap copper
view(45,30)
axis tight
daspect([1,1,.8])
lightangle(45,30);
set(gcf,’Renderer’,’zbuffer’); lighting phong
isonormals(Ds,hiso)
set(hcap,’AmbientStrength’,.6)
set(hiso,’SpecularColorReflectance’,0,’SpecularExponent’,50)
the 3D viewing like below. But, if you look at the same coordinate, (148, 109), its not show the count itself (332). its show the z coordinate. How to do for the 3D viewing(isosurface) can stored also the counts itself (332)?? image acquisition, image processing, image segmentation, digital image processing, image analysis, image MATLAB Answers — New Questions
Can’t install MATLAB Conector (online MATLAB) although downloaded from mathworks site
I have MATLAB online working. Tried to install MATLAB connector to synchronize with my laptop. On Preferances cannot find Controls -> Connector.
Also tried to dowload from Mathworks. Dowloaded ok, but double clicking got error: "Must be downloaded from Apps Store"?
Please help. Thanks.I have MATLAB online working. Tried to install MATLAB connector to synchronize with my laptop. On Preferances cannot find Controls -> Connector.
Also tried to dowload from Mathworks. Dowloaded ok, but double clicking got error: "Must be downloaded from Apps Store"?
Please help. Thanks. I have MATLAB online working. Tried to install MATLAB connector to synchronize with my laptop. On Preferances cannot find Controls -> Connector.
Also tried to dowload from Mathworks. Dowloaded ok, but double clicking got error: "Must be downloaded from Apps Store"?
Please help. Thanks. matlab connector, problems MATLAB Answers — New Questions
writeline stuck on busy when serial device connected to port not turned on.
I have a serial connection to an external device, which works perfect if the unit is connected and on, but if the unit is off or disconnected, the check on the serial port using writeline, writeread, or fprintf all result in Matlab getting stuck on busy. My PC is using a PCIe serial card, so the COM PORTs are present and the serialport function sets up the COM PORT for communication.
SComPort = 17;
SBaudRate = 9600;
SDataBits = 8;
SParity = "none";
SStopBits = 1;
SFlowControl = "hardware";
STimeout = 1;
SWriteTerminator = "CR";
SReadTerminator = "CR/LF";
try
SComm = serialport(sprintf(‘COM%i’,SComPort), SBaudRate,’Timeout’, STimeout);
SComm.DataBits = SDataBits;
SComm.Parity = SParity;
SComm.StopBits = SStopBits;
SComm.FlowControl = SFlowControl;
bSComm = true;
objS_IO.Valid = true;
configureTerminator(SComm, SReadTerminator, SWriteTerminator)
catch
disp(‘Unable to find S comm port!’);
bSComm = false;
SComm = [];
s = -1;
end
% All of these functions error out with the device disconnected or turned off.
response = writeread(SComm,"version");
writeline(SComm, "version");I have a serial connection to an external device, which works perfect if the unit is connected and on, but if the unit is off or disconnected, the check on the serial port using writeline, writeread, or fprintf all result in Matlab getting stuck on busy. My PC is using a PCIe serial card, so the COM PORTs are present and the serialport function sets up the COM PORT for communication.
SComPort = 17;
SBaudRate = 9600;
SDataBits = 8;
SParity = "none";
SStopBits = 1;
SFlowControl = "hardware";
STimeout = 1;
SWriteTerminator = "CR";
SReadTerminator = "CR/LF";
try
SComm = serialport(sprintf(‘COM%i’,SComPort), SBaudRate,’Timeout’, STimeout);
SComm.DataBits = SDataBits;
SComm.Parity = SParity;
SComm.StopBits = SStopBits;
SComm.FlowControl = SFlowControl;
bSComm = true;
objS_IO.Valid = true;
configureTerminator(SComm, SReadTerminator, SWriteTerminator)
catch
disp(‘Unable to find S comm port!’);
bSComm = false;
SComm = [];
s = -1;
end
% All of these functions error out with the device disconnected or turned off.
response = writeread(SComm,"version");
writeline(SComm, "version"); I have a serial connection to an external device, which works perfect if the unit is connected and on, but if the unit is off or disconnected, the check on the serial port using writeline, writeread, or fprintf all result in Matlab getting stuck on busy. My PC is using a PCIe serial card, so the COM PORTs are present and the serialport function sets up the COM PORT for communication.
SComPort = 17;
SBaudRate = 9600;
SDataBits = 8;
SParity = "none";
SStopBits = 1;
SFlowControl = "hardware";
STimeout = 1;
SWriteTerminator = "CR";
SReadTerminator = "CR/LF";
try
SComm = serialport(sprintf(‘COM%i’,SComPort), SBaudRate,’Timeout’, STimeout);
SComm.DataBits = SDataBits;
SComm.Parity = SParity;
SComm.StopBits = SStopBits;
SComm.FlowControl = SFlowControl;
bSComm = true;
objS_IO.Valid = true;
configureTerminator(SComm, SReadTerminator, SWriteTerminator)
catch
disp(‘Unable to find S comm port!’);
bSComm = false;
SComm = [];
s = -1;
end
% All of these functions error out with the device disconnected or turned off.
response = writeread(SComm,"version");
writeline(SComm, "version"); writeline, readwrite, serialport MATLAB Answers — New Questions
Simmetry constraints in multivariate regression.
Hi everyone! I wanted to know if there is the possibility of doing a multivariate regression, forcing the resulting matrix to be symmetrical.Hi everyone! I wanted to know if there is the possibility of doing a multivariate regression, forcing the resulting matrix to be symmetrical. Hi everyone! I wanted to know if there is the possibility of doing a multivariate regression, forcing the resulting matrix to be symmetrical. regression MATLAB Answers — New Questions
Repeated-measures ANOVA with no between-factor
Hi all!
I am trying to perform a two-way repeated measures ANOVA by using the function fitrm and ranova. I have two within-factors (e.g. Condition & Side) and no between-subject factors. I tried the code below, based on the different topics on the mathworks help page. Cause I have no between-subjects factor I thought i should use ~1 as constant. However, I keep getting the following error:
Error using RepeatedMeasuresModel.fit (line 1347)
The between-subjects design must have full column rank.
Error in fitrm (line 77)
s = RepeatedMeasuresModel.fit(ds,model,varargin{:});
Error in Statistics_JvdH_versie5 (line 7778)
rm_APMoS_MSZP = fitrm(t_APMoS_MSZP,’CWSaff-CWS2laff~1′,’WithinDesign’,Condition)
Does anyone know how to solve this problem? Or know another way to perform this analysis in matlab.
See code below:
t_APMoS_MSZP = table(MoS_AP_side1_CWS_MSZP,MoS_AP_side2_CWS_MSZP,MoS_AP_side1_FWS_MSZP,…
MoS_AP_side2_FWS_MSZP,MoS_AP_side1_CWS2_MSZP,MoS_AP_side2_CWS2_MSZP…
,’VariableNames’,{‘CWSside1′,’CWSside2′,’FWSside1′,’FWSside2′,’CWS2side1′,’CWS2side2’});
Condition = table([1 1 2 2 3 3]’,[1 2 1 2 1 2]’,’VariableNames’,{‘Condition’ ‘Side’});
rm_APMoS_MSZP = fitrm(t_APMoS_MSZP,’CWSside1-CWS2side2~1′,’WithinDesign’,Condition)
[b1_APMoS,A_APMoS,C_APMoS,D_APMoS] = ranova(rm_APMoS_MSZP,’WithinModel’,’Condition*Side’);Hi all!
I am trying to perform a two-way repeated measures ANOVA by using the function fitrm and ranova. I have two within-factors (e.g. Condition & Side) and no between-subject factors. I tried the code below, based on the different topics on the mathworks help page. Cause I have no between-subjects factor I thought i should use ~1 as constant. However, I keep getting the following error:
Error using RepeatedMeasuresModel.fit (line 1347)
The between-subjects design must have full column rank.
Error in fitrm (line 77)
s = RepeatedMeasuresModel.fit(ds,model,varargin{:});
Error in Statistics_JvdH_versie5 (line 7778)
rm_APMoS_MSZP = fitrm(t_APMoS_MSZP,’CWSaff-CWS2laff~1′,’WithinDesign’,Condition)
Does anyone know how to solve this problem? Or know another way to perform this analysis in matlab.
See code below:
t_APMoS_MSZP = table(MoS_AP_side1_CWS_MSZP,MoS_AP_side2_CWS_MSZP,MoS_AP_side1_FWS_MSZP,…
MoS_AP_side2_FWS_MSZP,MoS_AP_side1_CWS2_MSZP,MoS_AP_side2_CWS2_MSZP…
,’VariableNames’,{‘CWSside1′,’CWSside2′,’FWSside1′,’FWSside2′,’CWS2side1′,’CWS2side2’});
Condition = table([1 1 2 2 3 3]’,[1 2 1 2 1 2]’,’VariableNames’,{‘Condition’ ‘Side’});
rm_APMoS_MSZP = fitrm(t_APMoS_MSZP,’CWSside1-CWS2side2~1′,’WithinDesign’,Condition)
[b1_APMoS,A_APMoS,C_APMoS,D_APMoS] = ranova(rm_APMoS_MSZP,’WithinModel’,’Condition*Side’); Hi all!
I am trying to perform a two-way repeated measures ANOVA by using the function fitrm and ranova. I have two within-factors (e.g. Condition & Side) and no between-subject factors. I tried the code below, based on the different topics on the mathworks help page. Cause I have no between-subjects factor I thought i should use ~1 as constant. However, I keep getting the following error:
Error using RepeatedMeasuresModel.fit (line 1347)
The between-subjects design must have full column rank.
Error in fitrm (line 77)
s = RepeatedMeasuresModel.fit(ds,model,varargin{:});
Error in Statistics_JvdH_versie5 (line 7778)
rm_APMoS_MSZP = fitrm(t_APMoS_MSZP,’CWSaff-CWS2laff~1′,’WithinDesign’,Condition)
Does anyone know how to solve this problem? Or know another way to perform this analysis in matlab.
See code below:
t_APMoS_MSZP = table(MoS_AP_side1_CWS_MSZP,MoS_AP_side2_CWS_MSZP,MoS_AP_side1_FWS_MSZP,…
MoS_AP_side2_FWS_MSZP,MoS_AP_side1_CWS2_MSZP,MoS_AP_side2_CWS2_MSZP…
,’VariableNames’,{‘CWSside1′,’CWSside2′,’FWSside1′,’FWSside2′,’CWS2side1′,’CWS2side2’});
Condition = table([1 1 2 2 3 3]’,[1 2 1 2 1 2]’,’VariableNames’,{‘Condition’ ‘Side’});
rm_APMoS_MSZP = fitrm(t_APMoS_MSZP,’CWSside1-CWS2side2~1′,’WithinDesign’,Condition)
[b1_APMoS,A_APMoS,C_APMoS,D_APMoS] = ranova(rm_APMoS_MSZP,’WithinModel’,’Condition*Side’); repeated-measures anova, between-subjects factors, within-subject factors, fitrm, ranova MATLAB Answers — New Questions
I got not logic current from motor which value from numbers suddenly 0 value. I think I have problem with the connection but still cannot find the mistake
Above, This is my model simulink
this my current from motor .
I think i having wrong connection from Dc motor,H-bridge,controlled pwm voltageAbove, This is my model simulink
this my current from motor .
I think i having wrong connection from Dc motor,H-bridge,controlled pwm voltage Above, This is my model simulink
this my current from motor .
I think i having wrong connection from Dc motor,H-bridge,controlled pwm voltage ev, simulink, battery, plot MATLAB Answers — New Questions
Error when using exportgraphics function to save large vector graphics with transparency
When I tried to save a large vector graphic with transparency information using the exportgraphics function on my PC, an error occurred.
MATLAB version: 9.12.0.2529717 (R2022a) Update 8
Operating system: Microsoft Windows 10 Pro Version 10.0 (Build 19045)
Java version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
After plotting a large 3D vector graphic with complex perspectives and transparency relationships in a figure, I attempted to run the following code to save the figure:
exportgraphics(gca, ‘picture1.emf’, ‘BackgroundColor’, ‘none’, ‘ContentType’, ‘vector’)
However, the program threw an error.
The error message was:
Problem while processing in an OutputHelper. java.nio.file.NoSuchFileException:
C:Usersroom250AppDataLocalTempemf6382030724281275533.tmp
com.mathworks.hg.util.OutputHelperProcessingException: Problem while processing in an
OutputHelper. java.nio.file.NoSuchFileException:
C:Usersroom250AppDataLocalTempemf6382030724281275533.tmp
at com.mathworks.hg.util.HGVectorOutputHelper.close(HGVectorOutputHelper.java:245)
Caused by: com.mathworks.hg.print.OutputProcessingException: java.nio.file.NoSuchFileException:
C:Usersroom250AppDataLocalTempemf6382030724281275533.tmp
at com.mathworks.hg.print.MWEMFVectorStrategy.endJob(MWEMFVectorStrategy.java:144)
at com.mathworks.hg.util.HGVectorOutputHelper.close(HGVectorOutputHelper.java:241)
Caused by: java.nio.file.NoSuchFileException:
C:Usersroom250AppDataLocalTempemf6382030724281275533.tmp
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:79)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
at sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:230)
at java.nio.file.Files.newByteChannel(Files.java:361)
at java.nio.file.Files.newByteChannel(Files.java:407)
at java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:384)
at java.nio.file.Files.newInputStream(Files.java:152)
at java.nio.file.Files.copy(Files.java:3068)
at com.mathworks.hg.print.MWEMFVectorStrategy.endJob(MWEMFVectorStrategy.java:142)
… 1 more
I tried running MATLAB as an administrator and on a PC with higher memory, but the error persisted, and the error message remained the same. In addition, I checked the available storage space on my computer, and I have at least 390 GB of free space.
When I saved the same figure without transparency information as an image (using exportgraphics(gca, ‘picture1.emf’, ‘BackgroundColor’, ‘none’, ‘ContentType’, ‘image’)), the exportgraphics function worked correctly.
Furthermore, I plotted a smaller image and tried again to save it using exportgraphics(gca, ‘picture1.emf’, ‘BackgroundColor’, ‘none’, ‘ContentType’, ‘vector’), and the result was correct.
So, it seems that the exportgraphics function may not support saving larger images, or is there another reason?When I tried to save a large vector graphic with transparency information using the exportgraphics function on my PC, an error occurred.
MATLAB version: 9.12.0.2529717 (R2022a) Update 8
Operating system: Microsoft Windows 10 Pro Version 10.0 (Build 19045)
Java version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
After plotting a large 3D vector graphic with complex perspectives and transparency relationships in a figure, I attempted to run the following code to save the figure:
exportgraphics(gca, ‘picture1.emf’, ‘BackgroundColor’, ‘none’, ‘ContentType’, ‘vector’)
However, the program threw an error.
The error message was:
Problem while processing in an OutputHelper. java.nio.file.NoSuchFileException:
C:Usersroom250AppDataLocalTempemf6382030724281275533.tmp
com.mathworks.hg.util.OutputHelperProcessingException: Problem while processing in an
OutputHelper. java.nio.file.NoSuchFileException:
C:Usersroom250AppDataLocalTempemf6382030724281275533.tmp
at com.mathworks.hg.util.HGVectorOutputHelper.close(HGVectorOutputHelper.java:245)
Caused by: com.mathworks.hg.print.OutputProcessingException: java.nio.file.NoSuchFileException:
C:Usersroom250AppDataLocalTempemf6382030724281275533.tmp
at com.mathworks.hg.print.MWEMFVectorStrategy.endJob(MWEMFVectorStrategy.java:144)
at com.mathworks.hg.util.HGVectorOutputHelper.close(HGVectorOutputHelper.java:241)
Caused by: java.nio.file.NoSuchFileException:
C:Usersroom250AppDataLocalTempemf6382030724281275533.tmp
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:79)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
at sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:230)
at java.nio.file.Files.newByteChannel(Files.java:361)
at java.nio.file.Files.newByteChannel(Files.java:407)
at java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:384)
at java.nio.file.Files.newInputStream(Files.java:152)
at java.nio.file.Files.copy(Files.java:3068)
at com.mathworks.hg.print.MWEMFVectorStrategy.endJob(MWEMFVectorStrategy.java:142)
… 1 more
I tried running MATLAB as an administrator and on a PC with higher memory, but the error persisted, and the error message remained the same. In addition, I checked the available storage space on my computer, and I have at least 390 GB of free space.
When I saved the same figure without transparency information as an image (using exportgraphics(gca, ‘picture1.emf’, ‘BackgroundColor’, ‘none’, ‘ContentType’, ‘image’)), the exportgraphics function worked correctly.
Furthermore, I plotted a smaller image and tried again to save it using exportgraphics(gca, ‘picture1.emf’, ‘BackgroundColor’, ‘none’, ‘ContentType’, ‘vector’), and the result was correct.
So, it seems that the exportgraphics function may not support saving larger images, or is there another reason? When I tried to save a large vector graphic with transparency information using the exportgraphics function on my PC, an error occurred.
MATLAB version: 9.12.0.2529717 (R2022a) Update 8
Operating system: Microsoft Windows 10 Pro Version 10.0 (Build 19045)
Java version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
After plotting a large 3D vector graphic with complex perspectives and transparency relationships in a figure, I attempted to run the following code to save the figure:
exportgraphics(gca, ‘picture1.emf’, ‘BackgroundColor’, ‘none’, ‘ContentType’, ‘vector’)
However, the program threw an error.
The error message was:
Problem while processing in an OutputHelper. java.nio.file.NoSuchFileException:
C:Usersroom250AppDataLocalTempemf6382030724281275533.tmp
com.mathworks.hg.util.OutputHelperProcessingException: Problem while processing in an
OutputHelper. java.nio.file.NoSuchFileException:
C:Usersroom250AppDataLocalTempemf6382030724281275533.tmp
at com.mathworks.hg.util.HGVectorOutputHelper.close(HGVectorOutputHelper.java:245)
Caused by: com.mathworks.hg.print.OutputProcessingException: java.nio.file.NoSuchFileException:
C:Usersroom250AppDataLocalTempemf6382030724281275533.tmp
at com.mathworks.hg.print.MWEMFVectorStrategy.endJob(MWEMFVectorStrategy.java:144)
at com.mathworks.hg.util.HGVectorOutputHelper.close(HGVectorOutputHelper.java:241)
Caused by: java.nio.file.NoSuchFileException:
C:Usersroom250AppDataLocalTempemf6382030724281275533.tmp
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:79)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
at sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:230)
at java.nio.file.Files.newByteChannel(Files.java:361)
at java.nio.file.Files.newByteChannel(Files.java:407)
at java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:384)
at java.nio.file.Files.newInputStream(Files.java:152)
at java.nio.file.Files.copy(Files.java:3068)
at com.mathworks.hg.print.MWEMFVectorStrategy.endJob(MWEMFVectorStrategy.java:142)
… 1 more
I tried running MATLAB as an administrator and on a PC with higher memory, but the error persisted, and the error message remained the same. In addition, I checked the available storage space on my computer, and I have at least 390 GB of free space.
When I saved the same figure without transparency information as an image (using exportgraphics(gca, ‘picture1.emf’, ‘BackgroundColor’, ‘none’, ‘ContentType’, ‘image’)), the exportgraphics function worked correctly.
Furthermore, I plotted a smaller image and tried again to save it using exportgraphics(gca, ‘picture1.emf’, ‘BackgroundColor’, ‘none’, ‘ContentType’, ‘vector’), and the result was correct.
So, it seems that the exportgraphics function may not support saving larger images, or is there another reason? exportgraphics, error MATLAB Answers — New Questions
Help with assessing learners work
Hi All,
I am trying to assess students work for a reference solution below, but the problem is that when one thing is wrong, it is marking everything as wrong even though some elements of the learner’s code are correct. For example, say, UTM is correct but RREF is wrong, the assessment will also assess UTM as wrong. Is there a way I can fix this
function [AI UTM RREF INVA] = ROINVERSE(A)
%% Step 1: Matrix Validation
% Establish the Size of the Matrix [m n]
[m n] = size (A) ;
% Check if the Matrix is Square
if m~=n
error(‘Matrix Is Not Square’) ;
% Check Matrix For Singularity
elseif det(A) == 0
error(‘Matrix Is Not Invertible Since |A|=0’) ;
% Inform The User The Matrix Can Be Inverted
else
disp(‘The Matrix Is Invertible’) ;
end
%% Step 2: Augmented Matrix AI
AI = [A eye(m)] ;
%% Step 3: Upper Triangular Matrix UTM
UTM = AI ;
for i = 1:m
% Making All The Pivots = 1
UTM(i,:) = UTM(i,:)./UTM(i,i)
for j = i+1:n
% Making Values Below Pivots Equal to Zero
UTM(j,:) = UTM(j,:)-UTM(j,i)*UTM(i,:)
end
end
%% Step 4: Reduced Row Echelon Form RREF
RREF = UTM ;
for k = 1:(m-1)
for l = k+1:n
RREF(k,:) = RREF(k,:)-RREF(k,l)*RREF(l,:)
end
end
%% Step 5: Extract The Inverse Matrix INVA
INVA = RREF(1:m,(n+1):end)
endHi All,
I am trying to assess students work for a reference solution below, but the problem is that when one thing is wrong, it is marking everything as wrong even though some elements of the learner’s code are correct. For example, say, UTM is correct but RREF is wrong, the assessment will also assess UTM as wrong. Is there a way I can fix this
function [AI UTM RREF INVA] = ROINVERSE(A)
%% Step 1: Matrix Validation
% Establish the Size of the Matrix [m n]
[m n] = size (A) ;
% Check if the Matrix is Square
if m~=n
error(‘Matrix Is Not Square’) ;
% Check Matrix For Singularity
elseif det(A) == 0
error(‘Matrix Is Not Invertible Since |A|=0’) ;
% Inform The User The Matrix Can Be Inverted
else
disp(‘The Matrix Is Invertible’) ;
end
%% Step 2: Augmented Matrix AI
AI = [A eye(m)] ;
%% Step 3: Upper Triangular Matrix UTM
UTM = AI ;
for i = 1:m
% Making All The Pivots = 1
UTM(i,:) = UTM(i,:)./UTM(i,i)
for j = i+1:n
% Making Values Below Pivots Equal to Zero
UTM(j,:) = UTM(j,:)-UTM(j,i)*UTM(i,:)
end
end
%% Step 4: Reduced Row Echelon Form RREF
RREF = UTM ;
for k = 1:(m-1)
for l = k+1:n
RREF(k,:) = RREF(k,:)-RREF(k,l)*RREF(l,:)
end
end
%% Step 5: Extract The Inverse Matrix INVA
INVA = RREF(1:m,(n+1):end)
end Hi All,
I am trying to assess students work for a reference solution below, but the problem is that when one thing is wrong, it is marking everything as wrong even though some elements of the learner’s code are correct. For example, say, UTM is correct but RREF is wrong, the assessment will also assess UTM as wrong. Is there a way I can fix this
function [AI UTM RREF INVA] = ROINVERSE(A)
%% Step 1: Matrix Validation
% Establish the Size of the Matrix [m n]
[m n] = size (A) ;
% Check if the Matrix is Square
if m~=n
error(‘Matrix Is Not Square’) ;
% Check Matrix For Singularity
elseif det(A) == 0
error(‘Matrix Is Not Invertible Since |A|=0’) ;
% Inform The User The Matrix Can Be Inverted
else
disp(‘The Matrix Is Invertible’) ;
end
%% Step 2: Augmented Matrix AI
AI = [A eye(m)] ;
%% Step 3: Upper Triangular Matrix UTM
UTM = AI ;
for i = 1:m
% Making All The Pivots = 1
UTM(i,:) = UTM(i,:)./UTM(i,i)
for j = i+1:n
% Making Values Below Pivots Equal to Zero
UTM(j,:) = UTM(j,:)-UTM(j,i)*UTM(i,:)
end
end
%% Step 4: Reduced Row Echelon Form RREF
RREF = UTM ;
for k = 1:(m-1)
for l = k+1:n
RREF(k,:) = RREF(k,:)-RREF(k,l)*RREF(l,:)
end
end
%% Step 5: Extract The Inverse Matrix INVA
INVA = RREF(1:m,(n+1):end)
end matlab grader, assessments MATLAB Answers — New Questions