Clear Filters
Clear Filters

How to display contour levels for some specific levels

13 views (last 30 days)
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.

Accepted Answer

VBBV
VBBV on 30 Jan 2024
Edited: VBBV on 30 Jan 2024
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 Comments
University
University on 31 Jan 2024
Edited: University on 31 Jan 2024
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 on 31 Jan 2024
Edited: University on 31 Jan 2024
Please ignore this. I have been able to do it. Thank you

Sign in to comment.

More Answers (0)

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!