I want to break down my 3d graph into 2d graphs.

Hello Everyone,
I have a 3D derived graph. In this 3D graph, I want to obtain graphs such as x-z graph where y=constant and y-z graph where x=constant value. Additonal I want to take the derivatives of these graphs.
I leave the code below.
Thank you for your support.
T=273:1:420; %axisy
% x=0:0.1:10;
x = linspace(0, 0.35, 22);
Txm=1:1:148;
Txn=1.21:1:148.21;
Txmn=Txn-Txm; % X=0.21 (axis x measured first value)
Txk=1:1:148;
Txmk=Txk-Txm; % X=0; (axis x measured second value)
%lamda11=0.002547*(T.^2)+-0.01608*T+ 7162 ; %axis z(y) function
%lamda22=0.004723*(T.^2) +0.07403*T + 6962 ; %axis z(y) function
lamda__11= 0.00472 .*(T.^2)+0.0740 .*T+8.623e+03 %lamda %Eg(0)
lamda__11 = 1×148
1.0e+03 * 8.9950 8.9976 9.0003 9.0030 9.0057 9.0084 9.0111 9.0138 9.0165 9.0192 9.0220 9.0247 9.0275 9.0302 9.0330 9.0358 9.0386 9.0414 9.0442 9.0471 9.0499 9.0527 9.0556 9.0585 9.0613 9.0642 9.0671 9.0700 9.0729 9.0758
lamda__44= 0.00255 .*(T.^2)-0.0161 .*T+8.8230e+3 %lamda %Eg(0.21)
lamda__44 = 1×148
1.0e+03 * 9.0087 9.0100 9.0114 9.0128 9.0142 9.0156 9.0170 9.0184 9.0198 9.0212 9.0227 9.0241 9.0255 9.0270 9.0284 9.0299 9.0313 9.0328 9.0343 9.0357 9.0372 9.0387 9.0402 9.0417 9.0432 9.0447 9.0462 9.0477 9.0492 9.0507
cmtx11 = [0.00255 -0.0161 8.8230e+3; 0.00472 0.0740 8.623e+03];
cmtx = cmtx11 ; % Parameter Matrix
for k = 1:size(cmtx,2)
DM = [0 1; 0.21 1]; % Design Matrix
Bx(:,k) = DM \ cmtx(:,k); % Linear Regression For Each Coefficient
Ck(:,k) = DM * Bx(:,k); % Check Results
end
% format longG
% Bx
% Ck
format shortE
lambdafcn = @(T,x) [x 1]*Bx(:,1).*(T.^2) + [x 1]*Bx(:,2).*T + [x 1]*Bx(:,3); % 'lambda' Function Incorporating Linear Regression Parameters For Each Coefficient
[xm,Tm] = ndgrid(x, T); % Create Matrices From Vectors
xv = xm(:);
Tv = Tm(:);
for k = 1:numel(xm)
lambdav(k,:) = lambdafcn(Tv(k),xv(k)); % Create Vector Of 'lambda' Values For 'scatteredInterpolant'
end
Fz = scatteredInterpolant(Tm(:), xm(:), lambdav); % Create Interpolation Function
figure
surfc(Tm, xm, Fz(Tm,xm), 'EdgeColor','interp')
colormap(turbo)
xlabel('T (°K)')
ylabel('x')
zlabel('\lambda(T,x)')
title('\lambda(T,x) Surface With Linear Coefficient Interpolation')
axis([min(T) max(T) min(x) max(x) min(Fz(Tm,xm),[],'all') max(Fz(Tm,xm),[],'all')])
grid('on')
x_07 = 0.07+zeros(size(T(:))); % Define 'x' Vector
Line_07 = Fz(T(:), x_07); % Interpolate Line
figure
surfc(Tm, xm, Fz(Tm,xm), 'EdgeColor','interp')
colormap(turbo)
xlabel('T (°K)')
ylabel('x')
zlabel('\lambda(T,x)')
title('\lambda(T,x) Surface With Linear Coefficient Interpolation')
axis([min(T) max(T) min(x) max(x) min(Fz(Tm,xm),[],'all') max(Fz(Tm,xm),[],'all')])
grid('on')
hold on
plot3(T(:), x_07, Line_07, '-r', 'LineWidth',2)
hold off
text(max(T), 0.07, max(Line_07), ' \leftarrow Line at x=0.07', 'Horiz','left', 'Vert','middle', 'Rotation',40)

 Respuesta aceptada

The easiest way to do this is with the view function.
Use ‘view(90,0)’ for the ‘x-z’ view, and ‘view(0,0)’ for the ‘y-z’ view.
I added both of those at the end of the original code —
T=273:1:420; %axisy
% x=0:0.1:10;
x = linspace(0, 0.35, 22);
Txm=1:1:148;
Txn=1.21:1:148.21;
Txmn=Txn-Txm; % X=0.21 (axis x measured first value)
Txk=1:1:148;
Txmk=Txk-Txm; % X=0; (axis x measured second value)
%lamda11=0.002547*(T.^2)+-0.01608*T+ 7162 ; %axis z(y) function
%lamda22=0.004723*(T.^2) +0.07403*T + 6962 ; %axis z(y) function
lamda__11= 0.00472 .*(T.^2)+0.0740 .*T+8.623e+03 %lamda %Eg(0)
lamda__11 = 1×148
1.0e+03 * 8.9950 8.9976 9.0003 9.0030 9.0057 9.0084 9.0111 9.0138 9.0165 9.0192 9.0220 9.0247 9.0275 9.0302 9.0330 9.0358 9.0386 9.0414 9.0442 9.0471 9.0499 9.0527 9.0556 9.0585 9.0613 9.0642 9.0671 9.0700 9.0729 9.0758
lamda__44= 0.00255 .*(T.^2)-0.0161 .*T+8.8230e+3 %lamda %Eg(0.21)
lamda__44 = 1×148
1.0e+03 * 9.0087 9.0100 9.0114 9.0128 9.0142 9.0156 9.0170 9.0184 9.0198 9.0212 9.0227 9.0241 9.0255 9.0270 9.0284 9.0299 9.0313 9.0328 9.0343 9.0357 9.0372 9.0387 9.0402 9.0417 9.0432 9.0447 9.0462 9.0477 9.0492 9.0507
cmtx11 = [0.00255 -0.0161 8.8230e+3; 0.00472 0.0740 8.623e+03];
cmtx = cmtx11 ; % Parameter Matrix
for k = 1:size(cmtx,2)
DM = [0 1; 0.21 1]; % Design Matrix
Bx(:,k) = DM \ cmtx(:,k); % Linear Regression For Each Coefficient
Ck(:,k) = DM * Bx(:,k); % Check Results
end
% format longG
% Bx
% Ck
format shortE
lambdafcn = @(T,x) [x 1]*Bx(:,1).*(T.^2) + [x 1]*Bx(:,2).*T + [x 1]*Bx(:,3); % 'lambda' Function Incorporating Linear Regression Parameters For Each Coefficient
[xm,Tm] = ndgrid(x, T); % Create Matrices From Vectors
xv = xm(:);
Tv = Tm(:);
for k = 1:numel(xm)
lambdav(k,:) = lambdafcn(Tv(k),xv(k)); % Create Vector Of 'lambda' Values For 'scatteredInterpolant'
end
Fz = scatteredInterpolant(Tm(:), xm(:), lambdav); % Create Interpolation Function
figure
surfc(Tm, xm, Fz(Tm,xm), 'EdgeColor','interp')
colormap(turbo)
xlabel('T (°K)')
ylabel('x')
zlabel('\lambda(T,x)')
title('\lambda(T,x) Surface With Linear Coefficient Interpolation')
axis([min(T) max(T) min(x) max(x) min(Fz(Tm,xm),[],'all') max(Fz(Tm,xm),[],'all')])
grid('on')
x_07 = 0.07+zeros(size(T(:))); % Define 'x' Vector
Line_07 = Fz(T(:), x_07); % Interpolate Line
figure
surfc(Tm, xm, Fz(Tm,xm), 'EdgeColor','interp')
colormap(turbo)
xlabel('T (°K)')
ylabel('x')
zlabel('\lambda(T,x)')
title('\lambda(T,x) Surface With Linear Coefficient Interpolation')
axis([min(T) max(T) min(x) max(x) min(Fz(Tm,xm),[],'all') max(Fz(Tm,xm),[],'all')])
grid('on')
hold on
plot3(T(:), x_07, Line_07, '-r', 'LineWidth',2)
hold off
text(max(T), 0.07, max(Line_07), ' \leftarrow Line at x=0.07', 'Horiz','left', 'Vert','middle', 'Rotation',40)
figure
surfc(Tm, xm, Fz(Tm,xm), 'EdgeColor','interp')
colormap(turbo)
xlabel('T (°K)')
ylabel('x')
zlabel('\lambda(T,x)')
title('\lambda(T,x) Surface With Linear Coefficient Interpolation — ‘x-z’ View')
axis([min(T) max(T) min(x) max(x) min(Fz(Tm,xm),[],'all') max(Fz(Tm,xm),[],'all')])
grid('on')
hold on
plot3(T(:), x_07, Line_07, '-r', 'LineWidth',2)
hold off
text(max(T), 0.07, max(Line_07), ' \leftarrow Line at x=0.07', 'Horiz','left', 'Vert','middle', 'Rotation',40)
view(90, 0)
figure
surfc(Tm, xm, Fz(Tm,xm), 'EdgeColor','interp')
colormap(turbo)
xlabel('T (°K)')
ylabel('x')
zlabel('\lambda(T,x)')
title('\lambda(T,x) Surface With Linear Coefficient Interpolation — ‘y-z’ View')
axis([min(T) max(T) min(x) max(x) min(Fz(Tm,xm),[],'all') max(Fz(Tm,xm),[],'all')])
grid('on')
hold on
plot3(T(:), x_07, Line_07, '-r', 'LineWidth',2)
hold off
text(max(T), 0.07, max(Line_07), ' \leftarrow Line at x=0.07', 'Horiz','left', 'Vert','middle', 'Rotation',40)
view(0,0)
Use the print function with '-dpng' to save each of them as a separate image if that is what you want to do.
.

6 comentarios

Israfil
Israfil el 5 de En. de 2024
Movida: Voss el 5 de En. de 2024
Actually, I only want to see the T-lamda graphs at x=0, x=0.15 x= 20. For example, you can look at the images below.
I cannot see what the axis variables are in the plot images you provided (the axis labels are cut off), so I do not know what view arguments would work to get them. (I kept the earlier view calls here.)
That aside, plotting the lines instead of the surface is straightforward. The line values are calculated with this code segment:
Fz = scatteredInterpolant(Tm(:), xm(:), lambdav); % Create Interpolation Function
x_vals = [0, 0.15, 0.2];
x_lines = x_vals + zeros(size(T(:))) ;
for k = 1:numel(x_vals)
z_lines(:,k) = Fz(T(:), x_lines(:,k));
end
and then the plotting is done with this loop:
for k = 1:numel(x_vals)
plot3(T(:), x_lines(:,k), z_lines(:,k), '-', 'LineWidth',2, 'DisplayName',sprintf('x\\_val = %.1f',x_vals(k)))
end
After that, it is simply a matter of setting the view correctly to do what you want. You are plotting three vectors, so using plot3 is likely required, then rotate the axes with view.
It is possible to plot only two of the three vectors in a 2D using plot, however I do not know what those would be, again because I cannot see the axis labels. That is simply a matter of chosing the vectors to plot. The available options are: ‘T(:)’, ‘x_lines’ and ‘z_lines’. All are column vectors of the same length.
If you want to change the ‘x_vals’ values, that is straightforward. The rest of the code adapts automatically to those changes.
I also do not know how you want to designate the lines with the 'DisplayName' name-value pair, so I defer to you for that. There arre two separate plots, so you can change the sprintf call in each plot to be what you want. They do not have to be the same in both plots.
Try this —
T=273:1:420; %axisy
% x=0:0.1:10;
x = linspace(0, 0.35, 22);
Txm=1:1:148;
Txn=1.21:1:148.21;
Txmn=Txn-Txm; % X=0.21 (axis x measured first value)
Txk=1:1:148;
Txmk=Txk-Txm; % X=0; (axis x measured second value)
%lamda11=0.002547*(T.^2)+-0.01608*T+ 7162 ; %axis z(y) function
%lamda22=0.004723*(T.^2) +0.07403*T + 6962 ; %axis z(y) function
lamda__11= 0.00472 .*(T.^2)+0.0740 .*T+8.623e+03; %lamda %Eg(0)
lamda__44= 0.00255 .*(T.^2)-0.0161 .*T+8.8230e+3; %lamda %Eg(0.21)
cmtx11 = [0.00255 -0.0161 8.8230e+3; 0.00472 0.0740 8.623e+03];
cmtx = cmtx11 ; % Parameter Matrix
for k = 1:size(cmtx,2)
DM = [0 1; 0.21 1]; % Design Matrix
Bx(:,k) = DM \ cmtx(:,k); % Linear Regression For Each Coefficient
Ck(:,k) = DM * Bx(:,k); % Check Results
end
% format longG
% Bx
% Ck
format shortE
lambdafcn = @(T,x) [x 1]*Bx(:,1).*(T.^2) + [x 1]*Bx(:,2).*T + [x 1]*Bx(:,3); % 'lambda' Function Incorporating Linear Regression Parameters For Each Coefficient
[xm,Tm] = ndgrid(x, T); % Create Matrices From Vectors
xv = xm(:);
Tv = Tm(:);
for k = 1:numel(xm)
lambdav(k,:) = lambdafcn(Tv(k),xv(k)); % Create Vector Of 'lambda' Values For 'scatteredInterpolant'
end
Fz = scatteredInterpolant(Tm(:), xm(:), lambdav); % Create Interpolation Function
x_vals = [0, 0.15, 0.2];
x_lines = x_vals + zeros(size(T(:))) ;
for k = 1:numel(x_vals)
z_lines(:,k) = Fz(T(:), x_lines(:,k));
end
figure
% surfc(Tm, xm, Fz(Tm,xm), 'EdgeColor','interp')
colormap(turbo)
xlabel('T (°K)')
ylabel('x')
zlabel('\lambda(T,x)')
title('\lambda(T,x) Surface With Linear Coefficient Interpolation — ‘x-z’ View')
axis([min(T) max(T) min(x) max(x) min(Fz(Tm,xm),[],'all') max(Fz(Tm,xm),[],'all')])
grid('on')
hold on
for k = 1:numel(x_vals)
plot3(T(:), x_lines(:,k), z_lines(:,k), '-', 'LineWidth',2, 'DisplayName',sprintf('x\\_val = %.1f',x_vals(k)))
end
hold off
legend('Location','best')
view(90, 0)
figure
% surfc(Tm, xm, Fz(Tm,xm), 'EdgeColor','interp')
colormap(turbo)
xlabel('T (°K)')
ylabel('x')
zlabel('\lambda(T,x)')
title('\lambda(T,x) Surface With Linear Coefficient Interpolation — ‘x-z’ View')
axis([min(T) max(T) min(x) max(x) min(Fz(Tm,xm),[],'all') max(Fz(Tm,xm),[],'all')])
grid('on')
hold on
for k = 1:numel(x_vals)
plot3(T(:), x_lines(:,k), z_lines(:,k), '-', 'LineWidth',2, 'DisplayName',sprintf('x\\_val = %.1f',x_vals(k)))
end
hold off
legend('Location','best')
view(0,0)
I will need more details and clarification of what you want to plot to provide further help with the 2D plots.
.
Israfil
Israfil el 6 de En. de 2024
Movida: Dyuman Joshi el 6 de En. de 2024
Thank you. In the graph below, we need to keep the T value constant.
As far as I can see, in this graph the T value is variable x constant.
Like this
And since I cannot define the function of these graphs, I cannot differentiate it.
Can you show derivative graphs as well?
I still do not understand what you want to plot, since the axis labels are still not visible.
Howegver this may at least get us closer. I could not get it to plot correctly without the loop (maybe it is just too early). The plotted lines appear to be linear, so I did a linear regression on them to get the slopes (derivatives). If they are in fact not linear, use the gradient function to estimate the slopes at specific points:
for k = 1:numel(T_vals)
dLdx(k,:) = gradient(Lm(k,:), xm(k,:));
end
I tested that and it works (the gradient apppears to be constant).
The plot is at the end of the current code.
Try this —
T=273:1:420; %axisy
% x=0:0.1:10;
x = linspace(0, 0.35, 22);
Txm=1:1:148;
Txn=1.21:1:148.21;
Txmn=Txn-Txm; % X=0.21 (axis x measured first value)
Txk=1:1:148;
Txmk=Txk-Txm; % X=0; (axis x measured second value)
%lamda11=0.002547*(T.^2)+-0.01608*T+ 7162 ; %axis z(y) function
%lamda22=0.004723*(T.^2) +0.07403*T + 6962 ; %axis z(y) function
lamda__11= 0.00472 .*(T.^2)+0.0740 .*T+8.623e+03; %lamda %Eg(0)
lamda__44= 0.00255 .*(T.^2)-0.0161 .*T+8.8230e+3; %lamda %Eg(0.21)
cmtx11 = [0.00255 -0.0161 8.8230e+3; 0.00472 0.0740 8.623e+03];
cmtx = cmtx11 ; % Parameter Matrix
for k = 1:size(cmtx,2)
DM = [0 1; 0.21 1]; % Design Matrix
Bx(:,k) = DM \ cmtx(:,k); % Linear Regression For Each Coefficient
Ck(:,k) = DM * Bx(:,k); % Check Results
end
% format longG
% Bx
% Ck
format shortE
lambdafcn = @(T,x) [x 1]*Bx(:,1).*(T.^2) + [x 1]*Bx(:,2).*T + [x 1]*Bx(:,3); % 'lambda' Function Incorporating Linear Regression Parameters For Each Coefficient
[xm,Tm] = ndgrid(x, T); % Create Matrices From Vectors
xv = xm(:);
Tv = Tm(:);
for k = 1:numel(xm)
lambdav(k,:) = lambdafcn(Tv(k),xv(k)); % Create Vector Of 'lambda' Values For 'scatteredInterpolant'
end
Fz = scatteredInterpolant(Tm(:), xm(:), lambdav); % Create Interpolation Function
T_vals = [300:30:390 400].';
x_vals = [0, 0.15, 0.2];
x_lines = x_vals + zeros(size(T(:))) ;
for k = 1:numel(x_vals)
lambda_lines(:,k) = Fz(T(:), x_lines(:,k));
% lambda_pts(:,k) = interp1(T(:),x_lines(:,k),T_vals)
end
figure
% surfc(Tm, xm, Fz(Tm,xm), 'EdgeColor','interp')
colormap(turbo)
xlabel('T (°K)')
ylabel('x')
zlabel('\lambda(T,x)')
title('\lambda(T,x) Surface With Linear Coefficient Interpolation — ‘x-z’ View')
axis([min(T) max(T) min(x) max(x) min(Fz(Tm,xm),[],'all') max(Fz(Tm,xm),[],'all')])
grid('on')
hold on
for k = 1:numel(x_vals)
plot3(T(:), x_lines(:,k), lambda_lines(:,k), '-', 'LineWidth',2, 'DisplayName',sprintf('x\\_val = %.1f',x_vals(k)))
end
hold off
legend('Location','best')
view(-30,30)
[Tm,xm] = ndgrid(T_vals,x_vals);;
Lm = Fz(Tm,xm);
% figure
% plot3(Tm, xm, Lm, '.-')
% xlabel('T °K')
% ylabel('x')
% zlabel('\lambda')
% % legend(compose('T = %3d°K', T_vals), 'Location','best')
% axis('padded')
% grid on
% view(90,0)
figure
hold on
for k = 1:numel(T_vals)
plot(xm(k,:), Lm(k,:), '.-', 'LineWidth',1)
B(:,k) = [xm(k,:); ones(size(xm(k,:)))].' \ Lm(k,:).';
end
hold off
xlabel('x')
ylabel('\lambda')
legend(compose('T = %3d°K, Slope = %.1f', [T_vals B(1,:).']), 'Location','NW')
grid
axis('padded')
title('\lambda(x) For Various Temperatures')
Make appropriate changes to get the plot to appear as you want it to.
.
Thank you for your answer,
The final version with a few edits is as follows.
I did the derivation process as follows.
If you have a different suggestion, I can take it.
T=273:1:420; %axisy
% x=0:0.1:10;
x = linspace(0, 0.35, 22);
Txm=1:1:148;
Txn=1.21:1:148.21;
Txmn=Txn-Txm; % X=0.21 (axis x measured first value)
Txk=1:1:148;
Txmk=Txk-Txm; % X=0; (axis x measured second value)
%lamda11=0.002547*(T.^2)+-0.01608*T+ 7162 ; %axis z(y) function
%lamda22=0.004723*(T.^2) +0.07403*T + 6962 ; %axis z(y) function
lamda__11= 0.00472 .*(T.^2)+0.0740 .*T+8.623e+03; %lamda %Eg(0)
lamda__44= 0.00255 .*(T.^2)-0.0161 .*T+8.8230e+3; %lamda %Eg(0.21)
cmtx11 = [0.00255 -0.0161 8.8230e+3; 0.00472 0.0740 8.623e+03];
cmtx = cmtx11 ; % Parameter Matrix
for k = 1:size(cmtx,2)
DM = [0 1; 0.21 1]; % Design Matrix
Bx(:,k) = DM \ cmtx(:,k); % Linear Regression For Each Coefficient
Ck(:,k) = DM * Bx(:,k); % Check Results
end
% format longG
% Bx
% Ck
format shortE
lambdafcn = @(T,x) [x 1]*Bx(:,1).*(T.^2) + [x 1]*Bx(:,2).*T + [x 1]*Bx(:,3); % 'lambda' Function Incorporating Linear Regression Parameters For Each Coefficient
[xm,Tm] = ndgrid(x, T); % Create Matrices From Vectors
xv = xm(:);
Tv = Tm(:);
for k = 1:numel(xm)
lambdav(k,:) = lambdafcn(Tv(k),xv(k)); % Create Vector Of 'lambda' Values For 'scatteredInterpolant'
end
Fz = scatteredInterpolant(Tm(:), xm(:), lambdav); % Create Interpolation Function
x_vals = [0, 0.05 , 0.10 , 0.15, 0.2];
x_lines = x_vals + zeros(size(T(:))) ;
for k = 1:numel(x_vals)
z_lines(:,k) = Fz(T(:), x_lines(:,k));
end
figure
% surfc(Tm, xm, Fz(Tm,xm), 'EdgeColor','interp')
colormap(turbo)
xlabel('Temperature (°K)')
ylabel('Radiation Wavelength (Å)')
zlabel('\lambda(T,x)')
title('\lambda(T,x) Surface With Linear Coefficient Interpolation — ‘x-z’ View')
axis([min(T) max(T) min(x) max(x) min(Fz(Tm,xm),[],'all') max(Fz(Tm,xm),[],'all')])
grid('on')
hold on
for k = 1:numel(x_vals)
plot3(T(:), x_lines(:,k), z_lines(:,k), '-', 'LineWidth',2, 'DisplayName',sprintf('x\\_val = %.1f',x_vals(k)))
end
legend('λ(Eg(T)) ; x=0 ','λ(Eg(T)) ; x=0.05 ','λ(Eg(T)) ; x=0.10 ','λ(Eg(T)) ; x=0.15 ','λ(Eg(T)) ; x=0.20 ');
hold off
legend('Location','best')
view(90, 0)
%-----------------------------------------------------
%figure gereksiz
% surfc(Tm, xm, Fz(Tm,xm), 'EdgeColor','interp')
colormap(turbo)
xlabel('Temperature (°K)')
ylabel('x')
zlabel('Radiation Wavelength (Å)')
title('Change of Radiation Wavelength Depending on Temperature')
axis([min(T) max(T) min(x) max(x) min(Fz(Tm,xm),[],'all') max(Fz(Tm,xm),[],'all')])
grid('on')
hold on
%for k = 1:numel(x_vals)
% plot3(T(:), x_lines(:,k), z_lines(:,k), '-', 'LineWidth',2, 'DisplayName',sprintf('x\\_val = %.1f',x_vals(k)))
%end
hold off
legend('Location','best')
view(0,0)
%------------------------------------------------------------
figure
T_05 = 400+zeros(size(x(:)));
LineT_05 = Fz(T_05, x(:));
T_06 = 390+zeros(size(x(:)));
LineT_06 = Fz(T_06, x(:));
T_07 = 360+zeros(size(x(:)));
LineT_07 = Fz(T_07, x(:));
T_08 = 330+zeros(size(x(:)));
LineT_08 = Fz(T_08, x(:));
T_09 = 300+zeros(size(x(:)));
LineT_09 = Fz(T_09, x(:));
plot(x,LineT_09, x,LineT_08, x,LineT_07, x,LineT_06, x,LineT_05, 'LineWidth',2);
legend('T=300K ; λ(Eg(x))','T=330K ; λ(Eg(x))','T=360K ; λ(Eg(x))','T=390 ; λ(Eg(x))','T=400K ; λ(Eg(x))');
title('Compensation Parameter Dependence Ratio of Radiation Wavelength ');
xlabel('Compensation Parameter (x) ');
ylabel('Radiation Wavelength (Å) ');
%----------------------------------------------------------
figure;
for n=1:5
for m = 1:148
if(n==1)
z1(n,m) = z_lines(m,n);
elseif(n==2)
z2(1,m) = z_lines(m,n);
elseif(n==3)
z3(1,m) = z_lines(m,n);
elseif(n==4)
z4(1,m) = z_lines(m,n);
elseif(n==5)
z5(1,m) = z_lines(m,n);
else
end
end
end
T1=273:1:419
T1 = 1×147
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302
z11=diff(z1);
z12=diff(z2);
z13=diff(z3);
z14=diff(z4);
z15=diff(z5);
plot(T1,z11, T1,z12, T1,z13, T1,z14, T1,z15, 'LineWidth',2);
axis([ 293 400 0 5]);
%legend('T=300K ; λ(Eg(x))','T=330K ; λ(Eg(x))','T=360K ; λ(Eg(x))','T=390 ; λ(Eg(x))','T=400K ; λ(Eg(x))');
legend('∂λ/∂(Eg(T)) ; x=0.20' ,'∂λ/∂(Eg(T)) ; x=0.15' ,'∂λ/∂(Eg(T)) ; x=0.10' ,'∂λ/∂(Eg(T)) ; x=0.05' ,'∂λ/∂(Eg(T)) ; x=0' )
title('Rate of Wavelength Change Depending on Temperature');
xlabel('Temperature (°K)');
ylabel('Wavelength Change Rate');
As always, my pleasure!
Those plots look great! I did not completely understand all the plots you wanted, however I am happy that my code allowed you to get the necessary information from your data to plot them.
The only suggestion I have is that using gradient rather than diff for numerical differentiation is usually preferable, since gradient produces an output the same size as the input, while diff produces an output that is one element less in the dimnensions along which it operates. The gradient values are also more reliable.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Aerospace Blockset en Centro de ayuda y File Exchange.

Productos

Versión

R2023a

Preguntada:

el 5 de En. de 2024

Comentada:

el 7 de En. de 2024

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by