# How can I Plot Curves all starting at a specific Point (0;900).?

1 view (last 30 days)
Andy on 26 Feb 2022
I plotted the following:
Now I want to shift all the curves in such a way that the fall off (at the ending of all curves) starts always at the point (0,900) for all of them.
To understand again: I want to shift each curve so that I only plot the end and this should always start at (0.900). Difficulty is that my data does not directly contain the Y value of 900 as shown here:
first column is time and the following shows temperature:
86 500 500 500 500 500 500
179 500 500 500 500 500 500
275 500 500 500 500 500 500
359 500 500 500 500 500 500
455 500 500 500 500 500 500
551 500 500 500 500 500 500
642 500 500 500 500 500 500
739 500 500 500 500 500 500
840 655 533 500 649 574 508
936 694 563 509 689 601 543
1016 730 589 547 723 630 572
1112 779 615 581 759 655 596
1208 832 655 626 812 688 625
1305 871 698 681 861 723 671
1399 904 722 730 905 746 723
1495 928 737 774 941 777 758
1592 945 766 811 973 807 777
1672 962 797 842 1005 837 801
1768 975 832 868 1027 868 830
1864 995 862 893 1050 894 862
1959 1017 892 918 1060 923 895
2055 1035 918 938 1071 953 931
2152 1055 943 958 1073 982 960
2248 1074 970 980 1078 1009 986
2344 1087 996 1001 1090 1029 1003
2424 1100 1014 1021 1101 1046 1013
2520 1113 1035 1036 1113 1065 1027
2617 1125 1049 1050 1126 1078 1044
2712 1136 1061 1063 1137 1088 1053
2808 1146 1075 1073 1144 1103 1067
2904 1157 1085 1082 1154 1114 1079
3000 1164 1091 1091 1157 1127 1095
3080 1144 1079 1075 1143 1108 1080
3176 1133 1072 1070 1126 1096 1074
3272 1125 1069 1067 1121 1087 1072
3369 1123 1065 1066 1111 1082 1069
3463 1116 1065 1065 1105 1079 1071
3560 1110 1064 1065 1102 1077 1069
3656 1108 1065 1068 1096 1076 1071
3736 1107 1068 1066 1097 1074 1071
3832 1106 1071 1070 1094 1072 1075
3928 1098 1069 1072 1091 1071 1077
4024 1098 1068 1072 1087 1060 1077
4120 1097 1075 1074 1088 1068 1078
4216 1096 1077 1076 1086 1065 1083
4312 1097 1078 1074 1085 1069 1081
4394 1096 1081 1076 1086 1067 1083
4488 1096 1081 1078 1084 1066 1085
4585 1099 1082 1081 1083 1063 1085
4681 1096 1084 1082 1084 1063 1088
4776 1097 1083 1086 1083 1064 1089
4872 1098 1086 1083 1084 1063 1091
4968 1095 1088 1087 1084 1063 1092
5049 1095 1086 1088 1084 1059 1091
5144 1095 1088 1090 1082 1059 1093
5240 1092 1091 1093 1083 1058 1091
5335 1096 1089 1093 1082 1059 1095
5433 1096 1088 1097 1083 1062 1093
5528 1092 1086 1096 1080 1061 1095
5624 1093 1087 1095 1082 1053 1097
5704 1093 1085 1096 1081 1056 1094
5800 1093 1086 1098 1079 1054 1092
5896 1093 1084 1098 1076 1052 1093
5991 1092 1085 1100 1076 1051 1092
6088 1096 1085 1103 1078 1053 1095
6183 1097 1085 1105 1076 1050 1092
6279 1015 1013 1040 987 966 1025
6358 926 933 965 898 887 939
6454 868 879 913 835 829 884
6550 820 839 879 773 774 842
6648 770 800 848 714 720 801
6744 724 762 817 663 674 762
6838 687 726 789 620 632 724
6934 649 692 759 583 596 688
7014 617 660 730 545 561 656
7111 590 630 707 505 525 625
7207 565 606 685 500 500 598
7303 538 583 663 500 500 573
7398 509 560 644 500 500 549
7495 500 537 626 500 500 519
7591 500 511 613 500 500 500
7670 500 500 597 500 500 500
7766 500 500 584 500 500 500
7863 500 500 571 500 500 500
7959 500 500 554 500 500 500
8053 500 500 538 500 500 500
8150 500 500 520 500 500 500
8246 500 500 504 500 500 500
8342 500 500 500 500 500 500
8422 500 500 500 500 500 500
How can I write an easy code to plot them all starting (the ending) at (0,900).?

Alberto Cuadra Lara on 26 Feb 2022
Edited: Alberto Cuadra Lara on 26 Feb 2022
Hi Andy, if I have understood correctly this should work
% MATLAB Answers: How can I Plot Curves all starting at a specific Point (0, 900)?
% 1. Reproduce problem
myplot(data, 'Step 1')
% 2. Set data to correspond with the fall off
ind = find(data(:, 1) == 6183);
myplot(data(ind:end, :), 'Step 2');
% 3. Move data to the desired location (0, 900), e.g., apply offset
x_offset = 6183;
y_offset = (data(ind, 2:end) - 900);
[Nx, Ny] = size(data(ind:end, :));
data_offset = zeros(Nx, Ny);
data_offset(:, 1) = data(ind:end, 1) - x_offset;
data_offset(:, 2:end) = data(ind:end, 2:end) - y_offset;
myplot(data_offset, 'Step 3');
% SUB-PASS FUNCTIONS
function myplot(data, titlename)
% Plot data. First column represent the x range. The rest is a
% different set of y values.
[~, Ny] = size(data);
figure; hold on;
for i = 2:Ny
plot(data(:, 1), data(:, i));
end
title(titlename);
end
function data = load_data()
% Given data
data = [86 500 500 500 500 500 500
179 500 500 500 500 500 500
275 500 500 500 500 500 500
359 500 500 500 500 500 500
455 500 500 500 500 500 500
551 500 500 500 500 500 500
642 500 500 500 500 500 500
739 500 500 500 500 500 500
840 655 533 500 649 574 508
936 694 563 509 689 601 543
1016 730 589 547 723 630 572
1112 779 615 581 759 655 596
1208 832 655 626 812 688 625
1305 871 698 681 861 723 671
1399 904 722 730 905 746 723
1495 928 737 774 941 777 758
1592 945 766 811 973 807 777
1672 962 797 842 1005 837 801
1768 975 832 868 1027 868 830
1864 995 862 893 1050 894 862
1959 1017 892 918 1060 923 895
2055 1035 918 938 1071 953 931
2152 1055 943 958 1073 982 960
2248 1074 970 980 1078 1009 986
2344 1087 996 1001 1090 1029 1003
2424 1100 1014 1021 1101 1046 1013
2520 1113 1035 1036 1113 1065 1027
2617 1125 1049 1050 1126 1078 1044
2712 1136 1061 1063 1137 1088 1053
2808 1146 1075 1073 1144 1103 1067
2904 1157 1085 1082 1154 1114 1079
3000 1164 1091 1091 1157 1127 1095
3080 1144 1079 1075 1143 1108 1080
3176 1133 1072 1070 1126 1096 1074
3272 1125 1069 1067 1121 1087 1072
3369 1123 1065 1066 1111 1082 1069
3463 1116 1065 1065 1105 1079 1071
3560 1110 1064 1065 1102 1077 1069
3656 1108 1065 1068 1096 1076 1071
3736 1107 1068 1066 1097 1074 1071
3832 1106 1071 1070 1094 1072 1075
3928 1098 1069 1072 1091 1071 1077
4024 1098 1068 1072 1087 1060 1077
4120 1097 1075 1074 1088 1068 1078
4216 1096 1077 1076 1086 1065 1083
4312 1097 1078 1074 1085 1069 1081
4394 1096 1081 1076 1086 1067 1083
4488 1096 1081 1078 1084 1066 1085
4585 1099 1082 1081 1083 1063 1085
4681 1096 1084 1082 1084 1063 1088
4776 1097 1083 1086 1083 1064 1089
4872 1098 1086 1083 1084 1063 1091
4968 1095 1088 1087 1084 1063 1092
5049 1095 1086 1088 1084 1059 1091
5144 1095 1088 1090 1082 1059 1093
5240 1092 1091 1093 1083 1058 1091
5335 1096 1089 1093 1082 1059 1095
5433 1096 1088 1097 1083 1062 1093
5528 1092 1086 1096 1080 1061 1095
5624 1093 1087 1095 1082 1053 1097
5704 1093 1085 1096 1081 1056 1094
5800 1093 1086 1098 1079 1054 1092
5896 1093 1084 1098 1076 1052 1093
5991 1092 1085 1100 1076 1051 1092
6088 1096 1085 1103 1078 1053 1095
6183 1097 1085 1105 1076 1050 1092
6279 1015 1013 1040 987 966 1025
6358 926 933 965 898 887 939
6454 868 879 913 835 829 884
6550 820 839 879 773 774 842
6648 770 800 848 714 720 801
6744 724 762 817 663 674 762
6838 687 726 789 620 632 724
6934 649 692 759 583 596 688
7014 617 660 730 545 561 656
7111 590 630 707 505 525 625
7207 565 606 685 500 500 598
7303 538 583 663 500 500 573
7398 509 560 644 500 500 549
7495 500 537 626 500 500 519
7591 500 511 613 500 500 500
7670 500 500 597 500 500 500
7766 500 500 584 500 500 500
7863 500 500 571 500 500 500
7959 500 500 554 500 500 500
8053 500 500 538 500 500 500
8150 500 500 520 500 500 500
8246 500 500 504 500 500 500
8342 500 500 500 500 500 500
8422 500 500 500 500 500 500];
end
##### 2 CommentsShowHide 1 older comment
Alberto Cuadra Lara on 26 Feb 2022
Great!! I'm glad to hear this works. For the sake of clarity, I just updated the name of the offset variables

### Categories

Find more on Get Started with Statistics and Machine Learning Toolbox in Help Center and File Exchange

R2021b

### Community Treasure Hunt

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

Start Hunting!

Translated by