Do not sort Horizontal Axis

Hi,
I am trying to plot against [2 1.8 1.6 1.4 1.2 1 1.2 1.4 1.6 1.8 2] but it plots 2 lines against a [1-2] vector
Thank you in advance!

2 Comments

Sure,
A = [1:0.1:2];
m = length(A);
Ma = linspace(0,2.17,500);
n = length(Ma);
derecha = (0.5787./Ma).*(1 + 0.2.*Ma.^2).^3;
% for i = 1:m
% figure(i)
% plot(Ma,derecha)
% hold on
% plot(Ma,A(i)*ones(n,1))
% title(['Area: ',num2str(A(i))])
% end
A_conv = [inf flip(A)];
A_div = A(2:end);
Ma = [0 0.3053 0.3262 0.3435 0.3696 0.4001 0.4305 0.4697 0.5218...
0.5914 0.6914 1 1.374 1.535 1.661 1.766 1.857 1.935 2.009 2.079 2.14 2.17];
rel_P = [1 0.9360 0.9262 0.9163 0.9064 0.8965 0.8767 0.8556 0.8275...
0.7886 0.7247 0.5283 0.3285 0.2605 0.2167 0.185 0.1610 0.1420 0.1263 0.1139 0.1034 0.098];
% Parte a)
figure(1)
plot(Ma)
title('Evolución de Ma')
xlabel('Relación de areas A/A*')
ylabel('Número de Mach Ma')
I want to plot [A_conv A_div] in horizontal axis

Sign in to comment.

 Accepted Answer

Walter Roberson
Walter Roberson on 6 Jun 2020
it is not possible have a single unordered axes in MATLAB.
numeric axes are always sorted by numeric value. datetime axes are always sorted by increasing nanoseconds. duration axes are always sorted by increasing nanoseconds. polaraxes are always sorted by increasing radius or angle. I do not recall at the moment what mapping axes are sorted on, but they are sorted.
categorical axes are always sorted by internal numeric code associated with the category, which does not have to follow alphabetical order (but would be alphabetical by default).
You have two choices:
  1. you can use multiple axes. You would use this if it was important that datatips gave the correct output without having to program the datatip behaviour. You might need to link the axes zoom and pan and resize callbacks to get sensible behavior as the window on to the data changes.
  2. you can use a sorted axes in which you manipulate the text labels associated with the axes. If you also want datatips to work then you will need to program their behavior.

More Answers (0)

Categories

Find more on Graphics Object Properties in Help Center and File Exchange

Products

Tags

Community Treasure Hunt

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

Start Hunting!