How to display contour levels for some specific levels

18 次查看(过去 30 天)
Is it possible to display contour levels for some specific values?
Z = peaks;
figure
[C,h] = contour(Z,8);
clabel(C,h)
title('Contours Labeled Using clabel(C,h)')
For instance, I want only the values (-1.6727, -0.0448059, 0.0648059, 3.6634) to be displayed on the contour instead of all the values.

采纳的回答

VBBV
VBBV 2024-1-30
编辑:VBBV 2024-1-30
Do you mean like this ?
Z = peaks;
figure
[C,h] = contour(Z,8);
v = [-1.6727, -0.0448059, 0.0648059, 3.6634]
v = 1×4
-1.6727 -0.0448 0.0648 3.6634
clabel(C,h,v) % pass the values in Clabel function as input argument
title('Contours Labeled Using clabel(C,h)')
  2 个评论
University
University 2024-1-31
编辑:University 2024-1-31
Sorry to come back, I decided to use "text" function to do what I want but I still have a problem. On the attached the figure, I used text to display combination of each pairs of array, however I just want, for example pairs of L1(1), xi1(1), L1(2), xi1(2), L1(3), xi1(3)... not L1(1), xi1(1), L1(1), xi1(2), L1(1), xi1(3), ... L1(2), xi1(1), L1(2), xi1(2) to be displayed using the "text" funtion. See my code below:
xi=active_flow.xivals;
L =active_flow.Lvals;
xi1= [88.9474, 102.632, 88.9474, 123.158,75.2632, 75.2632, 116.315, 13.6842];
L1 = [1.4193e-06, 0.1069e-06, 1.76912e-06, 2.11895e-06, 3.8607-06, 5.26737e-06,...
6.31684e-06, 3.69825e-07];
fig3 = figure(3);
[C,h] = contourf(L, xi, intul, [min(min(intul)):1e-11:max(max(intul))],'ShowText','off','edgecolor','none');
c = colorbar;
c.TickLabelInterpreter='latex';
c.Label.String = '$\int u dy $';
c.Label.Interpreter = 'latex';
colormap jet
clabel(C,h)
hold on
for i=1:length(L)
for j=1:length(xi)
plot(L(i), xi(j), 'w.', 'LineWidth', 2, 'MarkerSize', 5)
for iL1 =1:length(L1)
for ixi1=1:length(xi1)
text(L1(iL1), xi1(ixi1), 'o', 'Color', 'red', 'FontSize',10)
end
end
end
end
set(gca,'clim',[min(min(intul)) max(max(intul))]);
University
University 2024-1-31
编辑:University 2024-1-31
Please ignore this. I have been able to do it. Thank you

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Contour Plots 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by