Unique function to return last duplicate value

8 vues (au cours des 30 derniers jours)
MH
MH le 26 Août 2024
Commenté : Voss le 27 Août 2024
Hi there,
Is there a way I can use the 'unique' function to return the last duplicate value instead of the first one? Refer to the images attached for clarity. Essentially I'm using
"[Sp_Au,ix] = unique(Data.SetPoint, 'stable');
DataE = Data(ix,:);"
to retireve the unique values as per the SetPoint column and save it into 'DataE', but instead of it starting at rows that correspond to the first "10", I want it to retrieve the last "10" row just before it starts increasing. Is there a way to do that?
So from table Data, instead of it taking rows (1,6,7,8,...etc), I want it export rows (5,6,7,8,9,...etc). So from the last duplicated value. Hope that makes sense.
  1 commentaire
Star Strider
Star Strider le 26 Août 2024
Did my answer to your previous question work?

Connectez-vous pour commenter.

Réponse acceptée

Voss
Voss le 27 Août 2024
Modifié(e) : Voss le 27 Août 2024
"The data is essentially a ramp up and then a 3 second pause then a ramp down and I want to [split] the data into two variables starting from the ramp up (last -50 to first 10) and then a ramp down variable (last 10 and first -50)"
Based on this clarifying comment, unique is not the appropriate tool for the task. Even if you divide the data into two segments with repeated -50's and 10's in each, you wouldn't achieve the desired result with a single unique call per segment because each call would need to somehow mix 'first' and 'last' (segment 1: last -50, first 10; segment 2: last 10, first -50).
I gather that you actually just want to capture two contiguous subsets of rows of data. Your attempted solution used unique, so that's what you asked about, and that's what the answers you got were about.
One way to solve the actual problem is with a few find calls:
data = readtable("Unique.xlsx");
Vmin = -50;
Vmax = 10;
V = data.SetPoint;
% the end of segment 1 is the first 10 in the data:
e1 = find(V == Vmax,1,'first');
% the start of segment 1 is the last -50 before the first 10:
s1 = find(V(1:e1) == Vmin,1,'last');
% the start of segment 2 is the last 10 in the data:
s2 = find(V == Vmax,1,'last');
% the end of segment 2 is the first -50 after the last 10:
e2 = find(V(s2:end) == Vmin,1,'first') + s2 - 1;
% split the data into two variables by segment:
data_1 = data(s1:e1,:);
data_2 = data(s2:e2,:);
% check the results:
disp(data_1)
SetPoint M1 M2 ________ ______ ______ -50 181.68 137.42 -49.88 181.89 137.45 -49.76 181.88 137.26 -49.639 181.71 136.92 -49.519 181.67 136.45 -49.399 181.77 136.22 -49.279 182.04 136.19 -49.158 183.08 136.44 -49.038 183.34 136.23 -48.918 183.53 136.03 -48.798 183.76 135.84 -48.677 185.12 135.78 -48.557 185.79 136.03 -48.437 186.11 136.1 -48.317 186.09 135.93 -48.196 186.04 134.89 -48.076 186.1 134.9 -47.956 186.25 135.07 -47.836 186.24 135.05 -47.715 186.09 133.94 -47.595 185.91 133.76 -47.475 185.8 133.84 -47.355 185.38 134.28 -47.234 185.33 134.56 -47.114 185.32 135.03 -46.994 185.13 135.37 -46.874 185.33 135.5 -46.754 185.73 136.06 -46.633 186.09 136.58 -46.513 186.3 136.86 -46.393 186.27 135.75 -46.273 186.45 135.72 -46.152 186.59 135.78 -46.032 186.99 135.89 -45.912 187.6 136.28 -45.792 187.78 136.38 -45.671 187.75 136.43 -45.551 187.73 135.54 -45.431 187.15 135.08 -45.311 186.62 134.67 -45.19 187 134.81 -45.07 187.29 135.01 -44.95 187.39 135.06 -44.83 187.28 135.09 -44.709 187.09 135.15 -44.589 187.14 134.96 -44.469 187.03 134.75 -44.349 186.75 134.23 -44.228 186.58 132.86 -44.108 186.49 132.6 -43.988 186.5 132.53 -43.868 186.62 132.67 -43.747 186.8 132.92 -43.627 187.16 132.92 -43.507 186.9 132.54 -43.387 186.54 130.88 -43.267 186.63 130.53 -43.146 186.99 130.65 -43.026 187.42 131.12 -42.906 187.74 131.79 -42.786 188.29 132.78 -42.665 188.19 132.65 -42.545 188 132.17 -42.425 187.41 130 -42.305 187.09 129.5 -42.184 187.32 129.81 -42.064 187.91 130.7 -41.944 188.37 131.45 -41.824 188.71 131.91 -41.703 188.82 132.01 -41.583 188.76 130.59 -41.463 188.89 130.56 -41.343 189.08 130.76 -41.222 189.3 131.21 -41.102 189.49 131.69 -40.982 189.6 131.49 -40.862 189.15 131.16 -40.741 188.79 130.72 -40.621 189.19 130.09 -40.501 189.44 130.1 -40.381 189.69 130.18 -40.261 189.79 130.24 -40.14 189.81 130.35 -40.02 189.69 129.84 -39.9 189.59 129.45 -39.78 190.04 128.47 -39.659 190.18 128.16 -39.539 190.15 127.97 -39.419 190.02 128.04 -39.299 189.92 128.29 -39.178 189.67 127.19 -39.058 189.49 126.9 -38.938 189.46 126.76 -38.818 189.77 126.39 -38.697 189.78 126.57 -38.577 190.06 127.05 -38.457 190.41 126.92 -38.337 190.31 126.74 -38.216 190.04 126.6 -38.096 189.91 126.71 -37.976 190.83 126.83 -37.856 191.02 127.24 -37.735 190.89 127.51 -37.615 190.49 126.66 -37.495 190.28 126.51 -37.375 190.05 126.5 -37.255 190.05 126.73 -37.134 190.24 126.94 -37.014 190.7 126.2 -36.894 190.6 125.89 -36.774 190.65 125.11 -36.653 190.95 125.39 -36.533 191.25 125.82 -36.413 191.54 126.21 -36.293 191.66 126.21 -36.172 191.77 125.93 -36.052 192.14 124.94 -35.932 193.66 124.55 -35.812 193.77 124.24 -35.691 193.75 124.2 -35.571 193.62 124.42 -35.451 193.27 124.62 -35.331 192.73 124.49 -35.21 192.34 124.2 -35.09 192.24 122.88 -34.97 192.48 122.67 -34.85 192.62 122.65 -34.729 192.47 122.74 -34.609 192.24 122.94 -34.489 191.98 123.17 -34.369 191.79 123.3 -34.248 192.44 122.5 -34.128 192.83 122.5 -34.008 193 122.66 -33.888 192.76 122.86 -33.768 192.25 123.05 -33.647 191.72 123.18 -33.527 191.41 123.22 -33.407 191.73 122.72 -33.287 192.3 122.24 -33.166 192.27 122.06 -33.046 192.21 122.16 -32.926 192.02 122.36 -32.806 191.76 122.47 -32.685 191.56 122.51 -32.565 191.55 122.42 -32.445 192.48 121.27 -32.325 192.42 120.9 -32.204 192.07 120.58 -32.084 191.57 120.46 -31.964 191.08 120.48 -31.844 190.75 120.57 -31.723 190.76 120.65 -31.603 191.12 119.96 -31.483 191.58 119.92 -31.363 191.6 120.04 -31.242 191.44 120.28 -31.122 191.09 120.46 -31.002 190.69 120.62 -30.882 190.38 120.68 -30.762 190.46 119.72 -30.641 190.39 118.88 -30.521 190.31 118.8 -30.401 190 118.8 -30.281 189.66 118.94 -30.16 189.4 119.13 -30.04 189.32 119.26 -29.92 189.39 119.23 -29.8 190.12 118.67 -29.679 190.44 118.3 -29.559 190.18 117.71 -29.439 189.82 117.26 -29.319 189.59 117.21 -29.198 189.65 117.53 -29.078 189.91 117.97 -28.958 190.77 117.18 -28.838 190.61 116.64 -28.717 190.29 115.47 -28.597 189.78 114.63 -28.477 189.4 114.21 -28.357 189.08 114.16 -28.236 188.82 114.31 -28.116 188.54 113.31 -27.996 188.82 113.37 -27.876 189.12 113.27 -27.756 189.5 112.61 -27.635 189.59 112.42 -27.515 189.78 112.62 -27.395 189.86 112.83 -27.275 190.14 112.06 -27.154 189.95 111.45 -27.034 189.8 111.07 -26.914 189.54 110.95 -26.794 189.02 111.05 -26.673 188.79 110.87 -26.553 188.43 110.51 -26.433 188.2 109.5 -26.313 187.95 109.24 -26.192 187.9 109.29 -26.072 187.85 109.37 -25.952 187.91 109.03 -25.832 187.92 108.81 -25.711 187.86 108.64 -25.591 187.76 108.53 -25.471 187.56 107.81 -25.351 187.33 107.67 -25.23 187.2 107.64 -25.11 187.13 107.54 -24.99 186.84 106.43 -24.87 186.75 105.73 -24.749 186.65 105.25 -24.629 186.55 104.98 -24.509 186.38 103.54 -24.389 186.42 103.27 -24.269 186.42 102.97 -24.148 186.55 102.76 -24.028 187.04 102.57 -23.908 187.33 102.69 -23.788 187.68 102.94 -23.667 187.82 103.01 -23.547 187.66 102.05 -23.427 187.44 101.51 -23.307 187.35 101.1 -23.186 187.2 100.61 -23.066 187.26 100.28 -22.946 187.19 100.03 -22.826 187.09 99.805 -22.705 186.57 98.597 -22.585 186.17 98.185 -22.465 185.96 97.957 -22.345 185.91 97.903 -22.224 186.09 98.06 -22.104 187.09 98.515 -21.984 186.94 98.191 -21.864 186.77 97.656 -21.743 186.6 97.409 -21.623 186.53 97.463 -21.503 186.51 97.6 -21.383 186.39 97.731 -21.263 186.17 97.688 -21.142 186.08 97.271 -21.022 185.87 96.897 -20.902 185.67 96.358 -20.782 185.36 95.989 -20.661 185.02 95.718 -20.541 184.75 95.533 -20.421 184.61 95.517 -20.301 184.57 95.564 -20.18 185 95.726 -20.06 184.91 94.77 -19.94 184.93 94.564 -19.82 184.96 94.554 -19.699 184.98 94.689 -19.579 184.9 94.773 -19.459 184.66 94.673 -19.339 184.56 93.951 -19.218 183.9 92.609 -19.098 183.85 92.261 -18.978 183.81 92.102 -18.858 183.67 92.068 -18.737 183.41 92.081 -18.617 183.19 92.131 -18.497 183.21 92.152 -18.377 183.57 90.965 -18.257 183.56 90.521 -18.136 183.37 90.079 -18.016 183.11 89.706 -17.896 182.86 89.414 -17.776 182.77 89.36 -17.655 182.87 89.476 -17.535 184.09 89.904 -17.415 183.87 89.654 -17.295 183.62 89.469 -17.174 183.42 89.404 -17.054 183.33 89.45 -16.934 183.48 89.724 -16.814 183.57 89.849 -16.693 183.85 89.065 -16.573 183.68 88.766 -16.453 183.36 88.403 -16.333 183.07 88.209 -16.212 182.81 88.151 -16.092 182.66 88.236 -15.972 182.58 88.24 -15.852 182.57 88.131 -15.731 182.47 87.052 -15.611 182.66 86.995 -15.491 182.66 86.931 -15.371 182.61 86.955 -15.251 182.45 87.014 -15.13 181.97 86.899 -15.01 181.45 86.661 -14.89 181.74 86.513 -14.77 182.07 86.192 -14.649 182.27 86.125 -14.529 182.18 85.821 -14.409 181.87 85.528 -14.289 181.46 85.246 -14.168 181.03 84.98 -14.048 180.7 84.446 -13.928 180.94 84.409 -13.808 181.6 84.233 -13.687 181.54 84.136 -13.567 181.26 84.041 -13.447 180.83 83.944 -13.327 180.41 83.959 -13.206 180 83.887 -13.086 180.32 83.849 -12.966 180.4 83.821 -12.846 180.7 83.662 -12.725 180.73 83.389 -12.605 180.55 82.993 -12.485 180.45 82.847 -12.365 180.39 82.934 -12.244 180.46 82.627 -12.124 180.19 82.284 -12.004 179.94 81.975 -11.884 179.82 81.896 -11.764 179.76 81.758 -11.643 179.73 81.658 -11.523 179.83 81.722 -11.403 179.86 81.299 -11.283 179.12 80.639 -11.162 178.31 79.932 -11.042 177.87 79.246 -10.922 178.26 79.583 -10.802 178.72 80.058 -10.681 179.01 80.436 -10.561 179.38 79.888 -10.441 179.2 79.49 -10.321 179.02 79.032 -10.2 178.93 78.54 -10.08 179.11 78.698 -9.9599 179.26 78.829 -9.8397 179.44 79.001 -9.7194 178.85 77.993 -9.5992 178.66 77.808 -9.479 178.56 77.727 -9.3587 178.41 77.571 -9.2385 178.47 76.485 -9.1182 178.63 76.389 -8.998 178.67 76.369 -8.8778 178.59 76.408 -8.7575 178.09 75.608 -8.6373 177.5 75.2 -8.517 177.28 75.075 -8.3968 177.2 74.066 -8.2766 177.18 74.139 -8.1563 177.17 74.285 -8.0361 177.04 74.381 -7.9158 176.91 74.471 -7.7956 176.49 73.667 -7.6754 177.34 73.688 -7.5551 177.35 73.173 -7.4349 177.15 72.74 -7.3146 176.95 72.631 -7.1944 176.95 72.974 -7.0741 176.78 73.215 -6.9539 176.49 72.876 -6.8337 176.08 72.739 -6.7134 176.42 72.503 -6.5932 176.42 72.202 -6.4729 176.37 72.011 -6.3527 176.25 71.936 -6.2325 176.37 71.945 -6.1122 176.42 71.933 -5.992 176.51 71.86 -5.8717 176.8 71.392 -5.7515 176.9 71.249 -5.6313 176.87 71.246 -5.511 176.53 71.151 -5.3908 176.01 70.959 -5.2705 175.29 70.19 -5.1503 174.67 69.671 -5.0301 174.83 69.564 -4.9098 175.12 69.643 -4.7896 175.3 69.675 -4.6693 175.3 69.651 -4.5491 175.16 69.542 -4.4289 174.71 68.184 -4.3086 175.08 67.817 -4.1884 174.88 67.361 -4.0681 174.62 67.061 -3.9479 174.35 66.932 -3.8277 174.21 67.02 -3.7074 174.41 67.38 -3.5872 174.67 67.632 -3.4669 175.24 67.305 -3.3467 175.07 66.879 -3.2265 174.75 66.37 -3.1062 174.54 66.147 -2.986 174.55 66.273 -2.8657 174.65 66.578 -2.7455 174.76 66.779 -2.6253 174.96 65.772 -2.505 175.04 65.735 -2.3848 175 65.828 -2.2645 174.77 65.894 -2.1443 174.52 65.948 -2.024 174.35 65.961 -1.9038 174.34 66.029 -1.7836 174.1 65.087 -1.6633 174.14 64.999 -1.5431 174.12 64.949 -1.4228 173.86 64.778 -1.3026 173.44 64.495 -1.1824 173.26 64.495 -1.0621 173.23 64.598 -0.94188 173.22 63.961 -0.82164 173.15 63.689 -0.7014 172.92 63.305 -0.58116 172.54 62.925 -0.46092 172.29 62.748 -0.34068 172.17 62.772 -0.22044 172.36 62.95 -0.1002 173.35 63.181 0.02004 173.15 62.737 0.14028 172.83 62.23 0.26052 172.49 61.917 0.38076 172.08 61.698 0.501 171.6 61.522 0.62124 171.22 61.458 0.74148 171.11 61.421 0.86172 170.9 61.068 0.98196 170.72 60.747 1.1022 170.52 60.535 1.2224 170.3 60.514 1.3427 170.33 60.783 1.4629 170.65 61.119 1.5832 170.94 60.546 1.7034 170.88 60.08 1.8236 170.58 59.804 1.9439 170.49 59.82 2.0641 170.5 59.983 2.1844 170.45 60.096 2.3046 170.33 60.073 2.4249 170.36 59.719 2.5451 170.46 59.347 2.6653 170.31 58.913 2.7856 169.94 58.462 2.9058 169.6 58.236 3.0261 169.24 58.273 3.1463 169.03 58.616 3.2665 168.86 58.857 3.3868 168.34 57.993 3.507 168.4 57.182 3.6273 168.34 56.97 3.7475 168.2 56.958 3.8677 167.95 56.983 3.988 167.78 57.202 4.1082 167.8 57.655 4.2285 168.38 57.935 4.3487 168.58 57.872 4.4689 169.06 57.652 4.5892 169.06 57.534 4.7094 168.68 57.275 4.8297 168.14 57.032 4.9499 167.64 56.805 5.0701 167.36 56.577 5.1904 167.26 56.151 5.3106 167.16 56.071 5.4309 166.61 56.291 5.5511 166.21 56.15 5.6713 165.83 56.072 5.7916 165.47 56.018 5.9118 165.09 55.9 6.0321 164.74 55.271 6.1523 164.98 55.709 6.2725 165.38 55.679 6.3928 165.55 55.751 6.513 165.53 55.734 6.6333 165.4 55.685 6.7535 165.2 55.57 6.8737 165.07 55.473 6.994 165.16 55.438 7.1142 164.53 54.791 7.2345 164.24 55.099 7.3547 164.75 56.083 7.4749 165.31 56.884 7.5952 165.36 57.089 7.7154 164.87 56.623 7.8357 163.04 54.323 7.9559 162.46 53.743 8.0762 162 53.241 8.1964 162.12 53.302 8.3166 162.21 53.462 8.4369 162.2 53.613 8.5571 162.27 53.79 8.6774 162.33 53.881 8.7976 162.2 53.553 8.9178 161.84 53.307 9.0381 161.45 52.966 9.1583 160.98 52.663 9.2786 160.64 52.57 9.3988 160.5 52.719 9.519 160.57 52.997 9.6393 160.86 52.934 9.7595 160.35 52.534 9.8798 160.21 52.476 10 160.12 52.538
disp(data_2)
SetPoint M1 M2 ________ ______ ______ 10 151.68 52.798 9.8798 151.71 52.768 9.7595 151.8 52.735 9.6393 151.82 52.79 9.519 151.16 53.004 9.3988 150.89 52.998 9.2786 150.53 52.942 9.1583 150.15 52.834 9.0381 149.9 52.717 8.9178 149.75 52.657 8.7976 149.59 52.677 8.6774 149.4 52.783 8.5571 149.17 54.437 8.4369 149.21 54.991 8.3166 149.13 55.248 8.1964 149.04 55.293 8.0762 149.08 55.251 7.9559 149.2 55.31 7.8357 149.28 55.401 7.7154 148.68 54.795 7.5952 148.61 55.966 7.4749 148.64 56.368 7.3547 148.83 56.688 7.2345 149.06 56.756 7.1142 149.26 56.556 6.994 149.34 56.143 6.8737 148.96 55.363 6.7535 148.71 55.965 6.6333 148.59 56.356 6.513 148.48 56.61 6.3928 148.55 56.847 6.2725 148.76 57.015 6.1523 148.83 57.019 6.0321 148.59 56.723 5.9118 147.19 55.922 5.7916 146.67 56.064 5.6713 146.92 56.348 5.5511 147.11 56.369 5.4309 147.14 56.151 5.3106 147.27 55.988 5.1904 147.56 56.059 5.0701 148.61 56.917 4.9499 148.77 57.006 4.8297 148.83 57.252 4.7094 148.94 57.208 4.5892 148.97 57.08 4.4689 148.98 56.948 4.3487 149.03 57.335 4.2285 148.91 57.338 4.1082 148.81 57.305 3.988 148.79 57.301 3.8677 149.45 57.926 3.7475 149.44 57.687 3.6273 149.14 57.128 3.507 148.75 57.357 3.3868 148.92 57.551 3.2665 149.47 58.046 3.1463 150.1 58.535 3.0261 149.68 58.165 2.9058 149.59 57.961 2.7856 149.43 58.674 2.6653 150.02 59.395 2.5451 150.62 59.892 2.4249 150.99 60.012 2.3046 151.15 59.898 2.1844 151.19 59.726 2.0641 151.08 60.597 1.9439 151.25 60.794 1.8236 151.34 60.697 1.7034 151.45 60.474 1.5832 151.77 60.214 1.4629 152.13 60.101 1.3427 152.47 60.103 1.2224 152.52 60.446 1.1022 152.36 60.94 0.98196 152.27 61.275 0.86172 152.25 61.514 0.74148 152.32 61.692 0.62124 152.35 61.732 0.501 152.47 61.68 0.38076 153.27 62.001 0.26052 153.31 62.152 0.14028 153.35 62.653 0.02004 153.58 62.948 -0.1002 153.72 63.055 -0.22044 153.71 62.902 -0.34068 153.42 62.449 -0.46092 152.81 61.78 -0.58116 153.08 62.033 -0.7014 153.47 62.407 -0.82164 153.68 63.061 -0.94188 153.97 63.299 -1.0621 154.33 63.524 -1.1824 154.55 63.803 -1.3026 154.49 64.09 -1.4228 154.39 64.088 -1.5431 154.09 63.874 -1.6633 153.86 63.686 -1.7836 154.09 64.073 -1.9038 154.32 64.447 -2.024 154.48 64.769 -2.1443 154.63 65.033 -2.2645 154.74 65.406 -2.3848 155.03 65.545 -2.505 155.36 65.73 -2.6253 155.73 65.961 -2.7455 155.91 66.317 -2.8657 155.92 66.401 -2.986 155.87 66.438 -3.1062 155.88 66.455 -3.2265 155.96 66.697 -3.3467 156.34 66.996 -3.4669 156.76 67.234 -3.5872 156.97 67.297 -3.7074 156.52 67.079 -3.8277 156.54 67.137 -3.9479 156.64 67.184 -4.0681 156.95 67.678 -4.1884 157.2 67.617 -4.3086 157.48 67.54 -4.4289 157.8 67.559 -4.5491 158.08 67.622 -4.6693 158.23 68.133 -4.7896 158.27 68.506 -4.9098 158.25 68.879 -5.0301 158.22 69.074 -5.1503 158.32 69.139 -5.2705 158.62 69.209 -5.3908 158.92 69.224 -5.511 159.1 69.316 -5.6313 158.61 70.198 -5.7515 158.63 70.429 -5.8717 158.97 70.895 -5.992 159.39 71.28 -6.1122 159.89 71.573 -6.2325 160.47 71.772 -6.3527 160.9 71.853 -6.4729 161.15 72.572 -6.5932 160.97 73.056 -6.7134 160.84 73.2 -6.8337 160.75 73.167 -6.9539 160.78 73.01 -7.0741 160.84 72.796 -7.1944 160.71 72.527 -7.3146 160.58 72.429 -7.4349 160.89 73.828 -7.5551 161.19 74.44 -7.6754 161.38 74.792 -7.7956 161.39 74.838 -7.9158 161.51 74.752 -8.0361 161.59 74.621 -8.1563 161.57 74.498 -8.2766 161.52 74.548 -8.3968 161.36 75.368 -8.517 161.06 75.29 -8.6373 161.1 75.376 -8.7575 161.47 75.602 -8.8778 162.01 75.74 -8.998 162.41 75.675 -9.1182 162.5 75.365 -9.2385 162.71 76.105 -9.3587 162.22 76.428 -9.479 162.2 76.894 -9.5992 162.09 76.887 -9.7194 162.13 76.686 -9.8397 162.37 76.496 -9.9599 162.66 76.33 -10.08 163.03 76.386 -10.2 163.39 77.824 -10.321 163.36 78.053 -10.441 163.37 78.075 -10.561 163.44 77.937 -10.681 163.57 77.739 -10.802 163.66 77.51 -10.922 163.76 77.512 -11.042 163.82 78.566 -11.162 164.17 79.876 -11.283 164.42 80.253 -11.403 164.66 80.398 -11.523 164.87 80.386 -11.643 165.01 80.331 -11.764 165.07 80.385 -11.884 164.52 80.914 -12.004 164.23 81.049 -12.124 164.22 81.072 -12.244 164.65 81.331 -12.365 165.25 81.611 -12.485 165.77 81.626 -12.605 166.1 81.39 -12.725 165.86 82.183 -12.846 165.92 82.51 -12.966 165.81 83.123 -13.086 165.78 83.259 -13.206 165.86 83.43 -13.327 166.01 83.557 -13.447 166.09 83.588 -13.567 166.23 83.763 -13.687 166.44 83.947 -13.808 166.89 84.29 -13.928 166.99 84.603 -14.048 167.23 84.722 -14.168 167.33 84.571 -14.289 166.34 83.487 -14.409 166.45 83.776 -14.529 166.86 84.249 -14.649 167.42 84.712 -14.77 167.87 84.966 -14.89 167.67 85.21 -15.01 167.42 85.55 -15.13 167.09 85.655 -15.251 166.77 85.516 -15.371 166.63 85.345 -15.491 166.65 85.184 -15.611 166.68 85.025 -15.731 166.68 85.574 -15.852 167.03 86.029 -15.972 167.48 86.897 -16.092 167.82 87.29 -16.212 168.12 87.544 -16.333 168.35 87.627 -16.453 168.43 87.625 -16.573 168.37 87.575 -16.693 167.71 87.866 -16.814 167.94 88.372 -16.934 168.07 88.892 -17.054 168.03 89.098 -17.174 167.84 89.181 -17.295 167.87 89.32 -17.415 168.03 89.502 -17.535 168.16 89.606 -17.655 168.19 90.07 -17.776 168.31 90.325 -17.896 168.99 91.199 -18.016 169.21 91.333 -18.136 169.13 90.938 -18.257 168.98 90.32 -18.377 168.82 89.744 -18.497 169.16 90.354 -18.617 169.15 90.325 -18.737 169.74 90.457 -18.858 169.93 90.477 -18.978 169.96 90.341 -19.098 170.19 90.348 -19.218 170.66 90.53 -19.339 171.03 90.674 -19.459 171.52 91.68 -19.579 171.61 92.086 -19.699 171.36 92.397 -19.82 171.34 92.525 -19.94 171.51 92.661 -20.06 171.64 92.581 -20.18 171.59 92.268 -20.301 171.6 92.046 -20.421 171.55 92.723 -20.541 171.75 93.207 -20.661 172 94.246 -20.782 171.68 94.328 -20.902 171.59 94.364 -21.022 171.71 94.393 -21.142 171.9 94.52 -21.263 172.07 94.848 -21.383 172.25 96.122 -21.503 172.09 96.455 -21.623 172.08 96.389 -21.743 172.08 96.673 -21.864 171.95 96.786 -21.984 171.71 96.726 -22.104 171.61 96.833 -22.224 171.71 97.308 -22.345 171.2 98.326 -22.465 170.8 98.96 -22.585 170.29 98.852 -22.705 170 98.798 -22.826 170.1 98.912 -22.946 170.35 98.958 -23.066 170.74 99.009 -23.186 170.9 99.628 -23.307 170.26 99.787 -23.427 169.91 100.07 -23.547 169.58 100.23 -23.667 169.42 100.36 -23.788 169.41 100.46 -23.908 169.62 100.6 -24.028 170.01 100.9 -24.148 170.27 102.22 -24.269 170.49 103.39 -24.389 170.49 103.9 -24.509 170.56 104.19 -24.629 170.75 104.3 -24.749 170.92 104.09 -24.87 171.03 103.86 -24.99 171.01 103.71 -25.11 170.86 103.99 -25.23 170.71 104.4 -25.351 170.44 104.9 -25.471 170.42 105.3 -25.591 170.77 105.79 -25.711 170.99 106.01 -25.832 170.95 105.89 -25.952 170.62 105.5 -26.072 169.89 105.4 -26.192 169.86 105.93 -26.313 169.73 106.36 -26.433 169.69 106.73 -26.553 169.72 106.87 -26.673 169.64 106.79 -26.794 169.35 106.54 -26.914 168.17 106.04 -27.034 168.13 107.09 -27.154 168.4 107.92 -27.275 168.82 108.67 -27.395 169.27 109.19 -27.515 169.5 109.37 -27.635 169.56 109.28 -27.756 168.88 109.02 -27.876 168.82 109.09 -27.996 168.57 109.58 -28.116 168.74 110 -28.236 169.1 110.34 -28.357 169.56 110.55 -28.477 169.84 110.54 -28.597 169.81 110.85 -28.717 169.74 110.75 -28.838 169.62 110.58 -28.958 169.59 110.48 -29.078 169.93 110.73 -29.198 170.47 111.19 -29.319 170.96 111.62 -29.439 170.88 111.97 -29.559 171.11 112.16 -29.679 171.11 112.03 -29.8 171.03 111.75 -29.92 170.84 111.41 -30.04 171.18 111.32 -30.16 171.49 111.73 -30.281 171.72 111.93 -30.401 171.78 111.79 -30.521 171.82 111.54 -30.641 171.94 111.44 -30.762 172.16 111.63 -30.882 172.44 112.9 -31.002 172.16 112.84 -31.122 171.78 112.98 -31.242 171.79 113.01 -31.363 172.05 113.05 -31.483 172.39 113.03 -31.603 172.59 112.92 -31.723 172.65 112.92 -31.844 172.1 113.28 -31.964 172.05 113.92 -32.084 171.98 114.17 -32.204 172.02 114.29 -32.325 172.17 114.2 -32.445 172.39 114.02 -32.565 172.6 113.85 -32.685 172.69 113.78 -32.806 172.71 115.07 -32.926 172.57 115.39 -33.046 172.48 115.47 -33.166 172.53 115.37 -33.287 172.62 114.98 -33.407 172.86 114.52 -33.527 173.07 114.17 -33.647 173 113.91 -33.768 172.54 115.16 -33.888 172.57 115.33 -34.008 172.62 115.27 -34.128 172.73 115.03 -34.248 172.89 114.59 -34.369 173.03 114.12 -34.489 173.24 113.9 -34.609 173.65 114.7 -34.729 173.9 115.45 -34.85 174.24 116 -34.97 174.68 116.47 -35.09 174.89 116.53 -35.21 174.92 116.19 -35.331 175.05 115.78 -35.451 175.45 116.69 -35.571 175.4 116.49 -35.691 174.98 116.34 -35.812 174.74 115.99 -35.932 174.62 115.66 -36.052 174.74 115.48 -36.172 175.45 116.57 -36.293 175.77 116.65 -36.413 176.03 116.67 -36.533 176.21 116.64 -36.653 176.25 117.02 -36.774 176.1 116.88 -36.894 175.9 116.77 -37.014 175.53 117.24 -37.134 175.72 117.45 -37.255 176.09 117.61 -37.375 176.48 117.76 -37.495 176.71 117.89 -37.615 176.53 118.48 -37.735 176.15 118.32 -37.856 175.71 118.95 -37.976 176.01 119.4 -38.096 176.48 119.6 -38.216 176.96 119.66 -38.337 177.45 119.73 -38.457 177.81 119.9 -38.577 177.26 120.48 -38.697 176.1 120.12 -38.818 175.66 119.92 -38.938 175.5 119.7 -39.058 175.66 119.57 -39.178 175.91 119.4 -39.299 176.2 119.3 -39.419 176.35 119.31 -39.539 175.02 120.81 -39.659 175.04 121.39 -39.78 175.34 121.77 -39.9 175.81 121.84 -40.02 176.15 121.61 -40.14 176.42 121.34 -40.261 176.44 121.85 -40.381 175.75 122.25 -40.501 175.64 122.27 -40.621 175.69 122.2 -40.741 176.03 122.19 -40.862 176.4 122.13 -40.982 175.91 122.64 -41.102 175.8 122.85 -41.222 175.27 123.66 -41.343 175.47 124.04 -41.463 175.7 124.11 -41.583 175.83 123.76 -41.703 175.82 123.24 -41.824 175.81 123.34 -41.944 175.73 123.47 -42.064 175.47 123.6 -42.184 175.28 124.72 -42.305 175.45 125.31 -42.425 175.64 125.62 -42.545 175.77 125.69 -42.665 175.66 125.51 -42.786 175.04 126 -42.906 174.83 126.27 -43.026 174.64 126.57 -43.146 174.48 127.4 -43.267 174.76 127.89 -43.387 175 128.07 -43.507 175.12 128 -43.627 175.09 127.81 -43.747 174.58 128.42 -43.868 174.48 128.53 -43.988 174.26 128.45 -44.108 173.69 128.71 -44.228 173.84 128.71 -44.349 173.98 128.54 -44.469 174.38 128.33 -44.589 174.63 128.76 -44.709 174.8 129.02 -44.83 174.79 129.06 -44.95 174.28 129.5 -45.07 174.64 129.89 -45.19 174.91 130.06 -45.311 174.59 130.39 -45.431 174.55 130.56 -45.551 174.51 130.7 -45.671 174.21 130.69 -45.792 173.81 130.52 -45.912 172.69 130.6 -46.032 172.73 131 -46.152 172.78 131.37 -46.273 172.39 132.38 -46.393 172.5 133.08 -46.513 172.73 133.81 -46.633 172.94 134.46 -46.754 173.17 135.13 -46.874 173.15 136.24 -46.994 173.09 136.55 -47.114 172.88 136.62 -47.234 172.32 137.32 -47.355 172.23 137.73 -47.475 172.28 138.09 -47.595 172.27 138 -47.715 172.13 137.64 -47.836 171.79 137.66 -47.956 172.04 137.84 -48.076 172.65 138.65 -48.196 172.65 138.42 -48.317 172.57 137.72 -48.437 172.68 137.19 -48.557 172.81 136.7 -48.677 172.82 136.24 -48.798 173.24 136.78 -48.918 173.14 137.03 -49.038 173.13 137.12 -49.158 173.39 137.22 -49.279 173.81 137.35 -49.399 174.05 137.3 -49.519 174.13 137.31 -49.639 173.22 139.19 -49.76 172.75 140.16 -49.88 172.71 140.43 -50 172.92 140.6
  2 commentaires
MH
MH le 27 Août 2024
oh man! thank you!!
Voss
Voss le 27 Août 2024
You're welcome!

Connectez-vous pour commenter.

Plus de réponses (1)

Ronit
Ronit le 26 Août 2024
Hello,
You can achieve this by using the unique function in MATLAB with a little twist. The unique function by default returns the first occurrence of each unique value when the 'stable' option is used. To get the last occurrence of each unique value, you can reverse the order of the data, apply unique, and then reverse the indices back to the original order.
To reverse the data, flipud can be used. Please find the documentation for more details: https://www.mathworks.com/help/matlab/ref/flipud.html
loadedData = load("Data.mat");
Data = loadedData.Data;
disp(Data);
SetPoint M1 M2 M3 ________ __ ___ __ 10 90 151 11 10 91 150 10 10 92 149 9 10.12 90 150 10 10.13 90 150 10 10.16 90 150 10
reversedData = flipud(Data);
[Sp_Au,ix] = unique(reversedData.SetPoint, 'stable');
DataE = flipud(reversedData(ix,:));
disp(DataE);
SetPoint M1 M2 M3 ________ __ ___ __ 10 92 149 9 10.12 90 150 10 10.13 90 150 10 10.16 90 150 10
Regards!
  5 commentaires
Ronit
Ronit le 27 Août 2024
Modifié(e) : Ronit le 27 Août 2024
Hi @MH
To achieve the desired separation of your data into two distinct segments one for the ramp-up (from the last -50 to the first 10) and one for the ramp-down (from the last 10 to the first -50), you can divide the data into two segments and apply the logic which is necessary for that segment using the arguments "first" or "last" while implementing the unique function.
Steven Lord
Steven Lord le 27 Août 2024
It sounds from this description:
The data is essentially a ramp up and then a 3 second pause then a ramp down and I want to slip the data into two variables starting from the ramp up (last -50 to first 10) and then a ramp down variable (last 10 and first -50) does that make sense? thank you!
that you don't actually want to use the unique function. It sounds like you're looking for change points or local extrema. If that's the case take a look at ischange, islocalmin, and islocalmax.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Data Import from MATLAB dans Help Center et File Exchange

Tags

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by