Borrar filtros
Borrar filtros

Find minimum value out of a 3D contour plot

11 visualizaciones (últimos 30 días)
Miguel Cardoso
Miguel Cardoso el 2 de En. de 2020
Comentada: Adam Danz el 2 de En. de 2020
Hi!
I plotted a contour graph and I want to find its minimum value i.e. without using a thinner mesh. However, I do not know what is the best way to get its minimum value as much accurate as possible. I do not know if an interpolation or fit is the best way to do that or if exists a better option. What I exactly want are the values of a and c for which M is minimum.
a=[SUMMARY(1,1) SUMMARY(10,1) SUMMARY(19,1) SUMMARY(28,1) SUMMARY(37,1) SUMMARY(46,1) SUMMARY(55,1) SUMMARY(64,1) SUMMARY(73,1)];
c=[SUMMARY(1,2) SUMMARY(2,2) SUMMARY(3,2) SUMMARY(4,2) SUMMARY(5,2) SUMMARY(6,2) SUMMARY(7,2) SUMMARY(8,2) SUMMARY(9,2)];
[x,y]=meshgrid(a,c);
M=zeros(9,9);
for i=1:length(SUMMARY)
if i<=9
M(1,i)=SUMMARY(i,5);
elseif i>9 && i<=18
M(2,i-9)=SUMMARY(i,5);
elseif i>18 && i<=27
M(3,i-18)=SUMMARY(i,5);
elseif i>27 && i<=36
M(4,i-27)=SUMMARY(i,5);
elseif i>36 && i<=45
M(5,i-36)=SUMMARY(i,5);
elseif i>45 && i<=54
M(6,i-45)=SUMMARY(i,5);
elseif i>54 && i<=63
M(7,i-54)=SUMMARY(i,5);
elseif i>63 && i<=72
M(8,i-63)=SUMMARY(i,5);
elseif i>72 && i<=81
M(9,i-72)=SUMMARY(i,5);
end
end
contourf(x,y,M)
xlabel('a (\AA)','Interpreter','Latex','FontSize',14,'FontWeight','bold');
ylabel('c (\AA)','Interpreter','Latex','FontSize',14,'FontWeight','bold');
Regard
  2 comentarios
Adam Danz
Adam Danz el 2 de En. de 2020
Attaching a mat file with experimental_data_1 and experimental_data_2 data would give us a full picture of what's going on in that contour plot.
Miguel Cardoso
Miguel Cardoso el 2 de En. de 2020
I added the full code and attached my experimental data.

Iniciar sesión para comentar.

Respuesta aceptada

Adam Danz
Adam Danz el 2 de En. de 2020
Editada: Adam Danz el 2 de En. de 2020
Below is a simplification of your code.
load('SUMMARY.mat')
a = SUMMARY([1 10 19 28 37 46 55 64 73],1).'; % Simpler
c = SUMMARY(1:9,2).'; % Simpler
[x,y]=meshgrid(a,c);
M = reshape(SUMMARY(:,5),size(x)).'; % This produces the same thing as your for-loop.
contourf(x,y,M);
xlabel('a (\AA)','Interpreter','Latex','FontSize',14,'FontWeight','bold');
ylabel('c (\AA)','Interpreter','Latex','FontSize',14,'FontWeight','bold');
axis equal; % added
colorbar % added
To find the (x,y) coordinate of the minimum z-value within your data,
[~, minIdx] = min(M(:));
[row,col] = ind2sub(size(M),minIdx);
xMin = x(row,col);
yMin = y(row,col);
% Plot this coordinate
hold on
plot(xMin, yMin, 'rx')
[Update] To interpolate and find minimum, (plot shown below)
% same as above
load('SUMMARY.mat')
a = SUMMARY([1 10 19 28 37 46 55 64 73],1).';
c = SUMMARY(1:9,2).';
[x,y]=meshgrid(a,c);
M = reshape(SUMMARY(:,5),size(x)).';
contourf(x,y,M,20);
% interpolate using cubic convolution (1000 points)
[xq,yq]=meshgrid(linspace(min(a),max(a),1000), linspace(min(c),max(c),1000));
Mq = interp2(x,y,M,xq,yq,'cubic');
% Same as above but acting on interpolated data
% Find min
[~, minIdx] = min(Mq(:));
[row,col] = ind2sub(size(Mq),minIdx);
xMin = xq(row,col);
yMin = yq(row,col);
% Mark min on plot
hold on
plot(xMin, yMin, 'rx', 'MarkerSize', 12)
200102 141811-Figure 1.png
  4 comentarios
Miguel Cardoso
Miguel Cardoso el 2 de En. de 2020
Editada: Miguel Cardoso el 2 de En. de 2020
It is possible to interpolate this region and get a point outside of my dataset? I do not know if I should use an interpolation or a fit.
Adam Danz
Adam Danz el 2 de En. de 2020
Yes! I've updated my answer to show how.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Contour Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by